Solving select count(*) performance problem
Solving select count(*) performance problem
irxn84
Posts: 12Questions: 5Answers: 0
Hi,
I have a problem with a datatable with lots of data. The select count(*) in postgresql is very slow so I have a performance issue on loading the page. My idea was: I just get the estimated amount of data, which is very fast. After showing the first data, I want to get the real amount of data in the background. So when this is finiished, I want to reload the page with the real data.
Does anyone had a similiar problem? How could this be solved?
Best regards,
Peter
This discussion has been closed.
Answers
A option would be to show not the real number of the pages, just show "Last" so when the user clicks on last, which is not often, I get the real amount then.
This is something that is been discussed a number of times before and it is something I would like to improve in DataTables, but currently it does need the row count if you are using server-side processing.
Allan
Hi Peter.
With a post like this, it may help if you could quantify "lots of data" and "very slow" for anyone who may be interested in comparisons and benchmarking.
I have 2 millions of rows and it takes about 30 seconds to get count(*).
Thanks!
That is definitely "lots" and "very slow"!