From: Adonias Malosso <malosso@gmail.com>
To: pgsql-performance@postgresql.org
Subject: 4s query want to run faster
Date: Thu, 21 Feb 2008 17:48:18 -0300
Message-ID: <8a5d3c890802211248k7d9dfbb5ndd645358a84130a7@mail.gmail.com> (raw)
Hi all,
The following query takes about 4s to run in a 16GB ram server. Any ideas
why it doesn´t use index for the primary keys in the join conditions?
select i.inuid, count(*) as total
from cte.instrumentounidade i
inner join cte.pontuacao p on p.inuid = i.inuid
inner join cte.acaoindicador ai on ai.ptoid = p.ptoid
inner join cte.subacaoindicador si on si.aciid = ai.aciid
where i.itrid = 2 and p.ptostatus = 'A'
group by i.inuid
having count(*) > 0
HashAggregate (cost=47905.87..47941.01 rows=2008 width=4)
Filter: (count(*) > 0)
-> Hash Join (cost=16307.79..46511.45 rows=185923 width=4)
Hash Cond: (si.aciid = ai.aciid)
-> Seq Scan on subacaoindicador si (cost=0.00..22812.17 rows=368817
width=4)
-> Hash (cost=16211.40..16211.40 rows=38556 width=8)
-> Hash Join (cost=9018.20..16211.40 rows=38556 width=8)
Hash Cond: (p.inuid = i.inuid)
-> Hash Join (cost=8908.41..15419.10 rows=39593
width=8)
Hash Cond: (ai.ptoid = p.ptoid)
-> Seq Scan on acaoindicador ai (cost=
0.00..4200.84 rows=76484 width=8)
-> Hash (cost=8678.33..8678.33 rows=92034
width=8)
-> Seq Scan on pontuacao p (cost=
0.00..8678.33 rows=92034 width=8)
Filter: (ptostatus = 'A'::bpchar)
-> Hash (cost=104.78..104.78 rows=2008 width=4)
-> Seq Scan on instrumentounidade i (cost=
0.00..104.78 rows=2008 width=4)
Filter: (itrid = 2)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: malosso@gmail.com
Subject: Re: 4s query want to run faster
In-Reply-To: <8a5d3c890802211248k7d9dfbb5ndd645358a84130a7@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox