views:

93

answers:

5

I would like to display to user a table which contains ~500,000 rows. The table should be calculated based on a file (i.e. the table is known at the beginning, and does not change). I guess that building the HTML text of this table is not a good idea in terms of memory performance. So how can I build such table ?

I would like user to be able to scroll the table using a vertical scroll bar. Is it possible to build on the fly only the visible part of the table ? I'm afraid to see delays because of this.

Is it a better idea to use server side programming rather than Javascript ?

I'm not restricted to any server side programming language, so any advise would be appreciated !

+3  A: 

Classic example of where to use ajax.

Use javascript in combination with a server side script.

zaf
+5  A: 

Send the first 250-ish rows to the user, as he scrolls down, perhaps past row 200, fetch the next 250 rows, append to the table and so on.

This is a (ui) design pattern known as "Infinite scroll".

PatrikAkerstrand
+2  A: 

This really is a case for server-side pagination, I would say, maybe in combination with Ajax. A HTML table with 500.000 rows is going to crash a lot of browsers.

You're not specifying which server side technology you work with. If you update your question, I'm sure people will be able to give you some pointers.

Pekka
+4  A: 

Displaying 500,000 rows all at once to a user is a bad idea. Consider other options:

  • allow user to download file as CSV
  • show paginated (still not very useful)
  • provide filtering mechanisms (by date etc.) to allow the user to only see the data they need

If the users really needs to see all that data at once, then viewing it in the browser is one of the worst ways to do that - they should be using a tool made specifically for viewing data, like Tableau.

RedFilter
+1, 500000 rows is just too many for a human to process. At best you're just letting them delude themselves into thinking they've seen a decent sample of the data. Another +1 for mentioning that paging is not a good answer either
Joel Coehoorn
To back this up: if the user cares enough about the data to glance at each row for just one second, to will take them over 5 days to get to the bottom. It is quite likely they are interested in particular rows (then add pagination and a filtering mechanism, think Google search results) or aggregate data (think Wolfram Alpha graphs and figures).
Douglas
A: 

Is it possible to build on the fly only the visible part of the table ?

If you build a "fake" scroll (e.g. jquery slider) you can retrieve parts of the table instead of the whole.

Rui Carneiro