laravel-livewire-tables icon indicating copy to clipboard operation
laravel-livewire-tables copied to clipboard

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

Open booni3 opened this issue 1 year ago • 4 comments

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

booni3 avatar Mar 13 '24 23:03 booni3

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: @.***>

lrljoe avatar Mar 16 '24 00:03 lrljoe

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.

stale[bot] avatar Apr 17 '24 02:04 stale[bot]

Still interested in this.

booni3 avatar Apr 17 '24 08:04 booni3

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.

stale[bot] avatar May 18 '24 18:05 stale[bot]

This is fixed in PR #1755

This does need a bit more testing before I can get it out for a release, but it should be released by the end of the week.

lrljoe avatar Jul 01 '24 14:07 lrljoe

Now released as v3.2.8, please advise if anything not as expected!

lrljoe avatar Jul 03 '24 22:07 lrljoe