Subject Re: [firebird-support] Re: Progress of a Stored Procedure Feedback
Author Ann W. Harrison
Alan McDonald wrote:
>> So can I do
>> select * from ext_table from row 8000 to 16000?
>>
>> Regards,
>>
>> Robert
>>
>
> SELECT FIRST 8000 SKIP 8000 FROM ext_table
>
>

When you do this, consider these three facts.

First, SELECT FIRST 8000 SKIP 8000 FROM ext_table actually
reads all 16000 rows. It doesn't return a value to the client
for the first 8000, but it does get them off disk which is
the expensive part. So, reading 80,000 row table by doing
a FIRST 8000 SKIP (8000 * iterator), actually reads 320,000
rows (8,000 for the first batch, 16,000 for the second, 24,000
for the third, etc.)

Second, there's no guarantee that any particular rows will
be in the first 8000 or 16000 unless you sort the result
set. If someone deletes 20 rows that previously appeared
the first 8000 and someone else inserts 20 new rows, those
new rows may well be stuck in the places of the old, deleted
rows.

Third, if you sort, unless you've got an index key that matches
the sort order exactly, Firebird will read and sort the whole
table - so getting 80,000 rows 8,000 at a time will actually
read and sort 80,000 rows 10 times....

Regards


Ann