Okipa / laravel-table

Generate tables from Eloquent models.
MIT License
533 stars 64 forks source link

RedirectRowAction to new window causes duplicate full query #150

Open HawtDogFlvrWtr opened 11 months ago

HawtDogFlvrWtr commented 11 months ago

Laravel: 10.28.0 laravel-table 5.3.1 php 8.2

When you set $openInNewWindow to true on a RedirectRowAction, it runs a full aggregate count search, and a full limit offset search to repopulate the table before redirecting. If you set $openInNewWindow to false, it just redirects properly. When you have have fast queries, this isn't an issue, but if you have pagination that takes a second or two to return due to the amount of data, it can take ages to load the original table, and just as long to redirect while it waits to run the original table generation queries again.

Set True:

new RedirectRowAction("search/show/$data->fdid", 'More Information', '<i class="fa-solid fa-circle-info fs-2"></i>', ['link-info', 'btn', 'btn-light-dark', 'btn-icon', 'btn-sm'], null, null, true),

[2023-10-18 11:40:02] local.INFO: select * from "users" where "id" = ? limit 1 [177] 
[2023-10-18 11:40:02] local.INFO: select * from "search" where "search"."fdid" = ? limit 1 ["49929"] 
[2023-10-18 11:40:02] local.INFO: select count(*) as aggregate from "search" inner join "types" on "types"."id" = "search"."type"  
[2023-10-18 11:40:02] local.INFO: select "search".*, "types"."name" as "name", "search"."md5" as "search.md5" from "search" inner join "types" on "types"."id" = "search"."file_type" order by "last_updated_on" desc limit 15 offset 0  
[2023-10-18 11:40:02] local.INFO: select * from "users" where "id" = ? limit 1 [177]

Set False:

new RedirectRowAction("search/show/$data->fdid", 'More Information', '<i class="fa-solid fa-circle-info fs-2"></i>', ['link-info', 'btn', 'btn-light-dark', 'btn-icon', 'btn-sm'], null, null, false),

[2023-10-18 11:41:14] local.INFO: select * from "users" where "id" = ? limit 1 [177] 
[2023-10-18 11:41:14] local.INFO: select * from "search" where "search"."fdid" = ? limit 1 ["49929"] 
[2023-10-18 11:41:14] local.INFO: select * from "users" where "id" = ? limit 1 [177]