Subject Re: [firebird-support] Re: Limiting fetched rows doesn't offer much performance benefit
Author Ivan Prenosil
>> Firebird will first use the index to create list of potentially
> matching records,
>> then it retrieves first 50 and stops, it will not read all rows
> internally.
>>
> It will not read all of the rows unless all of them match the query
> (which can happen sometimes with our situation). So then FB would
> read through millions when all we want is the first 50 it finds.
>
> When there is no ORDER BY clause it would be faster for FB to just
> return the first 50 that match.

It is exactly what FB is doing.

Or are you saying that first command is not significantly faster than second one?
SELECT FIRST 50 * FROM TABLE WHERE FLAG='Y';
SELECT COUNT(*) FROM TABLE;

Ivan