rappasoft / laravel-livewire-tables

A dynamic table component for Laravel Livewire
https://rappasoft.com/docs/laravel-livewire-tables/v2/introduction
MIT License
1.7k stars 319 forks source link

[Bug]: $this->paginationTotalItemCount included on all pagination types. Too heavy for "simple" #1687

Open booni3 opened 3 months ago

booni3 commented 3 months ago

What happened?

I have just upgraded to v3.

I have some tables with nearly 1M rows and some relationships. These worked fine in V2 using simple pagination.

V3 has introduced the code:

if ($this->isPaginationMethod('simple')) {

    $this->paginationTotalItemCount = $this->getBuilder()->count();

    return $this->getBuilder()->simplePaginate($this->getPerPage() === -1 ? $this->paginationTotalItemCount : $this->getPerPage(), ['*'], $this->getComputedPageName());

}

The getBuilder()->count() method is very heavy on big tables. On V2 I did not have the required indexes and tables would load in milliseconds. Without indexes on V3 my tables are timing out with > 30s load time.

After adding some additional indexes, I have gotten load times down between 500ms and 10s... but it is still a big performance from from V2 in this regard.

Do we need to be getting $this->paginationTotalItemCount = $this->getBuilder()->count(); for simple pagination? I thought the whole idea of simple was to make things more performant?

How to reproduce the bug

No response

Package Version

3

PHP Version

8.2.x

Laravel Version

10.34

Alpine Version

No response

Theme

None

Notes

No response

Error Message

No response

lrljoe commented 3 months ago

I'm on holiday at the mo, but will look at adding a toggle for enabling/disabling the behaviour in a release when I'm back (next month)

Sent from Outlook for Androidhttps://aka.ms/AAb9ysg


From: Adam @.> Sent: Thursday, March 14, 2024 7:35:44 AM To: rappasoft/laravel-livewire-tables @.> Cc: Subscribed @.***> Subject: [rappasoft/laravel-livewire-tables] [Bug]: $this->paginationTotalItemCount included on all pagination types. Too heavy for "simple" (Issue #1687)

What happened?

I have just upgraded to v3.

I have some tables with nearly 1M rows and some relationships. These worked fine in V2 using simple pagination.

V3 has introduced the code:

if ($this->isPaginationMethod('simple')) {

$this->paginationTotalItemCount = $this->getBuilder()->count();

return $this->getBuilder()->simplePaginate($this->getPerPage() === -1 ? $this->paginationTotalItemCount : $this->getPerPage(), ['*'], $this->getComputedPageName());

}

The getBuilder()->count() method is very heavy on big tables. On V2 I did not have the required indexes and tables would load in milliseconds. Without indexes on V3 my tables are timing out with > 30s load time.

After adding some additional indexes, I have gotten load times down between 500ms and 10s... but it is still a big performance from from V2 in this regard.

Do we need to be getting $this->paginationTotalItemCount = $this->getBuilder()->count(); for simple pagination? I thought the whole idea of simple was to make things more performant?

How to reproduce the bug

No response

Package Version

3

PHP Version

8.2.x

Laravel Version

10.34

Alpine Version

No response

Theme

None

Notes

No response

Error Message

No response

— Reply to this email directly, view it on GitHubhttps://github.com/rappasoft/laravel-livewire-tables/issues/1687, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AZATUOXO2WZ3CMZZAVB67WDYYDPFBAVCNFSM6AAAAABEVCRS7KVHI2DSMVQWIX3LMV43ASLTON2WKOZSGE4DKMBZHE3TEMA. You are receiving this because you are subscribed to this thread.Message ID: @.***>

stale[bot] commented 2 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

booni3 commented 2 months ago

Still interested in this.

stale[bot] commented 1 month ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.