Solving select count(*) performance problem

Solving select count(*) performance problem

irxn84irxn84 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

Answers

  • irxn84irxn84 Posts: 12Questions: 5Answers: 0

    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.

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin

    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

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    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.

  • irxn84irxn84 Posts: 12Questions: 5Answers: 0

    I have 2 millions of rows and it takes about 30 seconds to get count(*).

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    Thanks!
    That is definitely "lots" and "very slow"!

This discussion has been closed.