Subject Re: [firebird-support] Re: Sort memory
Author Ann W. Harrison
buppcpp wrote:

> That's what I thought, when I use DISTINCT I don't see the memory
> usage go up like it should.
>
> Example:
> mytable has ~2.1 million records.
>
> SELECT DISTINCT store_no FROM mytable;
> PLAN(SORT (MYTABLE NATURAL)) Max memory used is ~80MB
>
>
> SELECT store_no FROM mytable ORDER by onhand;
> PLAN(SORT (MYTABLE NATURAL)) Max memory used is ~280MB
>
> Can you check this out?
>

The difference is in the size of the elements being sorted. In the
first case, each element is just the store_no. In the second, its the
store_no and onhand. Firebird retrieves the required data first, then
sorts it. You may be thinking of a tag sort.

Regards,


Ann