Press "Enter" to skip to content

Finding Row Counts in Tables

Andy Brownsword wants a quick answer:

A question I ask myself often when exploring unfamiliar data sets. So here’s a quickie:

Click through for the script. This is a lot faster than SELECT COUNT(*), something that can really burn you when there are a few trillion rows in a table and your index scan interferes with ongoing operations. I’ve noticed that reading these counts from statistics is usually pretty solid, but generally, we’re interested in orders of magnitude, in which case 39,308,149 and 39,308,206 are close enough for purposes of understanding which tables are heftier.

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.