I have a fairly large table (10million rows) with a simple INTEGER PRIMARY KEY AUTOINCREMENT field.

Executing 'SELECT max(rowid) FROM MyTable' is very fast, as is 'SELECT min(rowid) FROM MyTable'.

However, 'SELECT max(rowid) - min(rowid) FROM MyTable' is slow (apparently accessing every row). Further, 'SELECT max(rowid) - 1 FROM MyTable' is slow - in fact using any constant in this expression (including 0) results in a slow query.

Finally, 'SELECT (SELECT  max(rowid) FROM MyTable') - 10' is very fast.

I am curious and would be grateful if someone can explain what is going on here.

guy


-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to