Subject Re: Problem slow sorting/distinct in Firebird
Author Dmitry Yemanov
15.11.2012 0:16, vanderlinde81 wrote:
>
> The Query in FireBird:
>
> SELECT FIRST 30 SKIP 0 distinct tr.IdLink, tr.IdTargetLink, tr.IdItem,
> tr.NodePosition

What about reordering the fields as

SELECT FIRST 30 SKIP 0 distinct tr.NodePosition, tr.IdLink,
tr.IdTargetLink, tr.IdItem

I'd expect PLAN to change to

> PLAN SORT (JOIN (TR INDEX (IDX_TREE3_2, IDX_TREE3_3), ART INDEX
> (RDB$PRIMARY2)))

that would eliminate one of the sorts.

> 873424 fetches, 0 marks, 12892 reads, 0 writes.

What is your page cache setting?


Dmitry