• Michael Ebaya (11/4/2010)


    sql.monkey (11/4/2010)


    The point was to use the index on the primary key column, which is usually a clustered index, and actually the tables I work with have tens of billions of rows.

    What you don't understand is that to find the min and max key values to use, you have to table scan the date column. You think aggregate functions like min() or max() come for free?

    I'll say it again. If you're getting good performance on that script, then either you have an index on the date column you don't know about, your tables are 1/1000 the size you say they are, or you simply made up the entire thing. There is no magic fairy dust that lets you quickly range scan a few billion values without an index.

    It works, and yes there are tens of billions of rows.