Community
Trick
How to improve table pagination performance
Aug 1, 2023
Table Builder
Integration

You may use the hammerstone/fast-paginate package. The theory for this feature can be found here.

You need to override the paginateTableQuery method. This should be on your Livewire component class. If you're using a panel resource, the Livewire component is your List or Manage page (in the /Pages directory of the resource). If you're using a panel relation manager, this class is the Livewire component.

use Illuminate\Contracts\Pagination\Paginator;
use Illuminate\Database\Eloquent\Builder;
 
protected function paginateTableQuery(Builder $query): Paginator
{
return $query->fastPaginate(($this->getTableRecordsPerPage() === 'all') ? $query->count() : $this->getTableRecordsPerPage());
}
Dan Harrin

Dan is a full-stack developer from the Cardiff, UK. He co-created Filament, and continues to lead development of the project. He works for Kirschbaum, a web development agency.

8
Articles
145
Stars