Subject | Re: Sort memory |
---|---|
Author | buppcpp |
Post date | 2005-06-07T04:49:03Z |
> If you use ORDER BY / GROUP BY / DISTINCT clauses and the enginechooses a
> SORT plan then the external sort happens. First, it tries to sortthe entire
> amount of data in the internal buffer of 1MB. If your recordsetdoesn't fit,
> the engine starts allocating new sort memory blocks of sizeSortMemBlockSize
> (allocation granularity) until it's able to sort the entirerecordset or
> SortMemUpperLimit of bytes becomes allocated. If the recordsetstill doesn't
> fit, the rest of the sort data goes to the temp files on disk.memory
>
> So, your understanding is correct, but you'll see such a maximum
> usage during quite big sorts only.That's what I thought, when I use DISTINCT I don't see the memory
>
>
> Dmitry
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?
Thanks