Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best approach for sortable table with a lot of data

On our web application, the search results are displayed in sortable tables. The user can click on any column and sort the result. The problem is some times, the user does a broad search and gets a lot of data returned. To make the sortable part work, you probably need all the results, which takes a long time. Or I can retrieve few results at a time, but then sorting won't really work well. What's the best practice to display sortable tables that might contain lots of data?


Thanks for all the advises. I will certainly going over these.

We are using an existing Javascript framework that has the sortable table; "lots" of results means hundreds. The problem is that our users are at some remote site and a lot of delay is the network time to send/receive data from the data center. Sorting the data at the database side and only send one page worth of results at a time is nice; but when the user clicks some column header, another round trip is done, which always add 3-4 seconds.

Well, I guess that might be the network team's problem :)

like image 830
Jon Avatar asked Mar 02 '23 07:03

Jon


1 Answers

Using sorting paging at the database level is the correct answer. If your query returns 1000 rows, but you're only going to show the user 10 of them, there is no need for the other 990 to be sent across the network.

Here is a mysql example. Say you need 10 rows, 21-30, from the 'people' table:

SELECT * FROM people LIMIT 21, 10 
like image 161
tyshock Avatar answered Mar 11 '23 19:03

tyshock