Subject Some fuel into TOP fire :)
Author Alexander V.Nevsky
After discussion about TOP/LIMIT I was interested about how
Firebird prepare result of the query for fetch. I made the next
experiment:

Create generator testgen

Create table test
(Code Integer Not null,
Primary key (Code))

Create Procedure Fill_TEST
As
Declare variable I Integer;
Begin I=0;
While (I<20000) do
begin I=I+1;
Insert into Test (Code) Values (:I);
end
End

Execute procedure Fill_Test

SHOW GENERATOR testgen
Generator TESTGEN, Next value: 0

And from D5/IBX application using TIBQuery:
Select Gen_Id(testgen, 1), Code from Test
where Code<10000

SHOW GENERATOR testgen
Generator TESTGEN, Next value: 4680

I've played with TIBQuery.BufferChunks and database cash buffers via
gfix, linked query to small grid. Result was already the same.
It's newly created test database, so records are placed
consequently. Page size is 1024.
I realize I'm alike now on curious monkey that press buttons on
"black box" and look what happened, but study all sources is too much
for my head. :) Can't anyone comment who play with cash - Firebird,
gds32 or IBX? And can it be controlled? And how TOP realization will
affect this?

Best regards.