Skip to main content

Cloud

Results count and custom paging

Be cautious when using the results table count if you are planning to build a paging control to wrap around your results.

After a query gets executed, a results table gets returned back. The count of the results table should be helpful in theory in order to build your paging feature so that user can go through all the results. Now, one thing to keep in mind with the table count is that it can either be an exact or an estimate count. The more results get returned, the greater the chance you will get an estimate. If we look closely at that estimate you will quickly notice that its value is constantly changing. If the count was only changing by small units it wouldn’t be too big of a problem but you will realize soon enough that it is changing so drastically in some cases that it is hard to still perceive this count as a useful value…

The "IsTotalRowsExact" property

One approach to work around this troublesome estimate is to use the boolean property " IsTotalRowsExact" that will help you flag those estimates and deal more efficiently with their inconsistencies. Once flagged, it is easier for you to determine if you should still be using that count or maybe a fixed value instead that will prevent your paging to become unstable. So basically, if the IsTotalRowsExact is true, use the results table count without fearing it will affect your paging. On the other hand, if the IsTotalRowsExact is false, accordingly use a value that will be used for your paging.

A decision needs to be taken when designing the paging control. If you want the user to be able to go through all of the paging from beginning to end and that from page results number one then you will have to deal with the fact that you will never get an accurate number of results thus never be able to have an accurate paging in this situation if using that results table count.

Round up/down the count

If you decide to display the counts somewhere in your paging , users might notice that the count is inconsistent for identical queries.. In this situation, you might want to consider rounding up/down the results count to the nearest hundred or thousand. This will provide to the user a more consistent experience.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Thomas DuPont

More from this Author

Follow Us
TwitterLinkedinFacebookYoutubeInstagram