in reply to Re^4: Ranking position in a SQL index (vairants of limit:sybase)
in thread Ranking position in a SQL index
And of course you should always include an ORDER BY clause as there is no guarantee that the result set will be int the "right" order.select ... from big_table limit 1000000, 1000010
On the other hand if you use a WHERE clause the server can limit the IO to the correct pages of data...
I have implemented versions of LIMIT by using a temporary table with an identity column, something like:
Obviously a lot of IO if you need to find rows located fairly deep into the result set, but acceptable for a pagination system where the user usually only looks at the first few pages...set rowcount 10010 select pk, id = syb_identity(10) into #tmp from big_table where some_c +ondition select b.* from big_table b, #tmp t where t.pk = b.pk and t.id >= 10000 set rowcount 0
Michael
|
|---|