shiraz zaidi, September 26, 2016 - 11:35 am UTC
Hi Chris,
Thanks for quick response on this. I totally agree with your recommendation of not retreving the count and have pagination aware of which page of total pages. But the customer needs this feature as its out of the product and they dont want to change it. On the advice of using a materialized view it seems that might be something we can use to achieve performance improvement, but i have some concerns regarding this. It seems that count(*) would be fired on every insert/delete/select commits. I am wondering if these atomic operations would be impacted with the count(*) query behind the scene if done synchronously with the db commit thread. If yes then i think we are moving the problem from one place to other and impacting OTP transactions. Can you please clarify on this? Thanks. And again appreciate your quick response on the previous comment.
September 27, 2016 - 12:14 am UTC
Option 1) Make the MV refresh on commit. As you said, this will have some performance impact, but the numbers are accurate.
Option 2) Make it refresh (say) every few minutes. Keeps the numbers very close with less performance impact.
"2" makes sense to me because after all, the moment you show the count on screen it is potentially out of date anyway (because transactions keep coming in). So a little bit more out of date really makes no difference.
Cheers,
Connor