Subject Re: [firebird-support] how to do a view (or work with) of top 80000 records
Author Gary Benade
>> ended up with this, based on your example
>>
>> select b.name, count(*) from customers c
>> join branches b on b.orderappend = c.branchcode and b.enabled = 'T'
>> where c.weighted_value >=
>> (SELECT FIRST 1 SKIP 80000 Weighted_Value FROM Customers
>> ORDER BY Weighted_Value DESC)
>> group by 1

> Ann Harrison wrote,
> Do you have any idea what the performance of that is likely to be?

PLAN (CUSTOMERS ORDER I_CUSTOMERS_WEIGHTEDVALUE)
PLAN SORT (JOIN (B NATURAL,C INDEX
(IDX_CUSTOMERS_BRANCHCODE,I_CUSTOMERS_WEIGHTEDVALUE)))

Prep 0.496 sec
Process 7.156 sec

65 non indexed reads on branches
160,037 indexed reads on customers

very very very impressive compared to the 5+ hour return times of my
original attempt :)

Regards
Gary