views:

39

answers:

1

Hi There, I just started using datatables (java script) for tabular data, due to js I am able to use functionalities like search, how many rows per page, sorting and pagination. Before using js, I was simply showing data in table(used Ajax for pagination), but unable to use above functionalities (Performance in this case was good). Now I am using jquery.dataTables.js and jquery.js files for the table structure. But problem is that this has badly hammered the performance of site, initially all the script was under one page only, then firefox was giving warnign message as "Unresponsive Script", then I just created separate file for the table, then I stopped getting this message but poorer performance. What I do is, fetch data from API, store it into database and then show it, but js is taking lot of time, sometimes it simply doesn't show the table when there is thousands of data.
I really need to use js for table but can't afford this poor performance. Has somebody got this problem before?
waiting for valuable advice.

+1  A: 

You cannot efficiently store and manipulate thousands of rows of data in Javascript. Database engines such as MySQL have all sorts of gubbins (indexes, caches), to speed up searching (queries). Javascript has none of this, and you can optimize your method of storage and searching algorithms as much as you want, but you will never accomplish an efficient solution.

Pagination should be on the server. The server sends you 30 rows of data, when you want more, you request more from the server; usually in the form of either a new page load to replace the current contents with another set of results, or an AJAX request to append/ prepend the new content to the existing.

When you want to search the data, using Javascript is fine for searching within the content you have on the page (~10's of rows), but for searching the whole dataset, send the query to the server and let your database engine do the work.

Matt
thank you matt, for your reply!
Rishi2686