Skip site navigation (1) Skip section navigation (2)

4s query want to run faster

From: "Adonias Malosso" <malosso(at)gmail(dot)com>
To: pgsql-performance(at)postgresql(dot)org
Subject: 4s query want to run faster
Date: 2008-02-21 20:48:18
Message-ID: 8a5d3c890802211248k7d9dfbb5ndd645358a84130a7@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-performance
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)

Responses

pgsql-performance by date

Next:From: Scott MarloweDate: 2008-02-21 20:58:04
Subject: Re: 4s query want to run faster
Previous:From: Vivek KheraDate: 2008-02-21 19:17:40
Subject: Re: 7 hrs for a pg_restore?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group