On Wed, Mar 16, 2011 at 4:45 AM, Uwe Bartels <
uwe.bartels@gmail.com> wrote:
> I'm having trouble with some sql statements which use an expression with
> many columns and distinct in the column list of the select.
> select distinct col1,col2,.....col20,col21
> from table1 left join table2 on <join condition>,...
> where
> <other expressions>;
>
> The negative result is a big sort with teporary files.
> -> Sort (cost=5813649.93..5853067.63 rows=15767078 width=80)
> (actual time=79027.079..81556.059 rows=12076838 loops=1)
> Sort Method: external sort Disk: 1086096kB
> By the way - for this query I have a work_mem of 1 GB - so raising this
> further is not generally possible - also not for one special command, due to
> parallelism.
>
> How do I get around this?
Hmm. It seems to me that there's no way to work out the distinct