Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best Practices for displaying large lists

Are there any best practices for returning large lists of orders to users?

Let me try to outline the problem we are trying to solve. We have a list of customers that have 1-5,000+ orders associated to each. We pull these orders directly from the database and present them to the user is a paginated grid. The view we have is a very simple "select columns from orders" which worked fine when we were first starting but as we are growing, it's causing performance/contention problems. Seems like there are a million and one ways to skin this cat (return only a page worth of data, only return the last 6 months of data, etc.) but like I said before just wondering if there are any resources out there that provide a little more hand holding on how to solve this problem.

We use SQL Server as our transaction database and select the data out in XML format. We then use a mixture of XSLT and Javascript to create our grid. We aren't married to the presentation solution but are married to the database solution.

like image 984
tk01 Avatar asked Jan 18 '26 09:01

tk01


1 Answers

My experience.

  1. Always set default values in the UI for the user that are reasonable. You don't want them clicking "Retrieve" and getting everything.
  2. Set a limit to the number of records that can be returned.
  3. Only return from the database the records you are going to display.
  4. If forward/backward consistencency is important, store the entire results set from the query in a temp table and return just the page you need to display. When paging up/down retrieve the next set from the temp table.
  5. Make sure your indexs are covering your queries.
  6. Use different queries for different purposes. Think "Open Orders" vs "Closed Orders". These might perfrom much better as different queries instead of one generic query.
  7. Set parameter defualts in the stored procedures. Protect your query from a UI that is not setting reasonable limits.

I wish we did all these things.

like image 73
Scott Bruns Avatar answered Jan 19 '26 22:01

Scott Bruns



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!