From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | Antti Jokipii <anttijokipii(at)gmail(dot)com> |
Cc: | pgsql-performance(at)postgresql(dot)org |
Subject: | Re: Query that uses lots of memory in PostgreSQL 9.2.1 in Windows 7 |
Date: | 2012-11-20 07:27:36 |
Message-ID: | CAFj8pRA_+55BjtzV6R2NvJDFyyND+izvYNZ+MBM3mUEWJZ1znA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
Hello
HashSetOp is memory expensive operation, and should be problematic
when statistic estimation is bad.
Try to rewritre this query to JOIN
Regards
Pavel Stehule
2012/11/15 Antti Jokipii <anttijokipii(at)gmail(dot)com>:
> Hi
>
> I tried to run quite simple query. For some reason query took lots of
> memory, more than 6GB.
> System start swapping, so I canceled it after 4 minutes. There were no other
> queries in same time.
>
> If I I understood my config correctly that is more than it should be. Is it
> bug or is there some other explanation?
>
> query:
>
> SELECT name, artist_count, aid INTO res FROM ac
> EXCEPT
> SELECT name, artist_count, aid FROM artist_credit;
>
> Explain gives following:
>
> HashSetOp Except (cost=0.00..297100.69 rows=594044 width=30)
> -> Append (cost=0.00..234950.32 rows=8286716 width=30)
> -> Subquery Scan on "*SELECT* 1" (cost=0.00..168074.62
> rows=5940431 width=29)
> -> Seq Scan on ac (cost=0.00..108670.31 rows=5940431
> width=29)
> -> Subquery Scan on "*SELECT* 2" (cost=0.00..66875.70 rows=2346285
> width=32)
> -> Seq Scan on artist_credit (cost=0.00..43412.85
> rows=2346285 width=32)
>
> PostgreSQL version: "PostgreSQL 9.2.1, compiled by Visual C++ build 1600,
> 64-bit"
> OS: Windows 7 (x64)
>
> Memory config:
> effective_cache_size=2048MB
> shared_buffers=1024MB
> work_mem=64MB
> maintenance_work_mem=256MB
>
> P.S. I got result witch I was after by changing query to use left join and
> isnull comparison.
> That query took little more than 500MB memory and execution took 41 seconds.
>
> Yours,
> Antti Jokipii
From | Date | Subject | |
---|---|---|---|
Next Message | Russell Keane | 2012-11-20 11:16:46 | FW: slow query on postgres 8.4 |
Previous Message | Andrew W. Gibbs | 2012-11-18 17:14:02 | partitioning versus clustering |