Houbsi's avatar
Level 18

How to handle a table with 19k+ Elements

Hi guys,

i know you would think, okay use the pagination. But if i need to use it in a ui.select2 or so that my users can search a really big database for adresses. I need a good workable solution. What i have currently explodes everytime the memory or the php loading time. I know i'm doing it to complicated, so there must be a laravel solution or a great package, which i can't find.

The can search on around 5 columns of each row the data.

0 likes
9 replies
MThomas's avatar

First of all make sure you have indexes on the searchable columns.

To display the data might datatables be an option? Or you can chunk your data?

Houbsi's avatar
Level 18

Thanks @MThomas,

I need it for a delivery system and they have to choose an adress i used the select ui plugin atm to have a searchable interface. But the new database i received... has to many elements for the page to load in a fast way. I already thought of taking it onto another page... but then i have to rewrite the whole page.

is it somehow possible to have my app somehow put out the actual list like an API and when you enter a letter/word it automatically redoes a new search and calls the api?

Ionut's avatar

In this cases I would use Elasticsearch and/or Redis. With a large dataset like yours making an autocomplete input "old-style" (by querying directly the database) might be a bit slow.

Houbsi's avatar
Level 18

@Ionut do you have any tutorial at hand for the integration or so?

Ionut's avatar

@Houbsi I've updated my reply. The links weren't formatted as I expected :D

Anyway, you are welcome. Hope it helps you.

1 like
pmall's avatar

I had to deal with this. The problem was not selecting data with eloquent but displaying the table. A 20k row html table is too much for the browser.

I ended up doing a custom javascript that display only 20 rows of the table that get refreshed when the user scrolls.

Edit : hum ok you were talking about your database table not an html table :D. 20k rows should be absolutely no problem to search. No need for elasticsearch.

bashy's avatar

Yeah should of put the title as "How to handle searching within a 19k database table" :P

Please or to participate in this conversation.