HNHacker News
TopNewBestAskShowJobs

leonidg

87 karma · joined March 25, 2010

submissionscomments
leonidg··on Constant factors: constantly foiling you
You are totally right, if all I wanted to do was figure out how many total rows there were, and needed to do this often, it would make much more sense to store that number in a separate table. Unfortunately, those particular queries were just simple examples illustrating the problem --- the real program actually needed to read and use the real data. :-)
leonidg··on Constant factors: constantly foiling you
That's a good question, and one I'm not entirely sure about. My guess is that the index itself is also scattered across the disk, since it gets added to at the same time as the rows get added. So in the real query, where we are reading actual data, and not just counting the number of rows, there are actually two seek costs --- seeking to finding the correct part of the index to read, and then seeking to find the row it points to.