From: | Francisco Reyes <lists(at)natserv(dot)com> |
---|---|
To: | pgsql General List <pgsql-general(at)postgresql(dot)org> |
Subject: | Dealing with complex queries |
Date: | 2003-02-03 21:32:10 |
Message-ID: | 20030203162150.E55262-100000@zoraida.natserv.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Any hints suggestions on dealing with complex queries.
Most of the queries I have done with pgsql up to this point have been
fairly straight forward compared to a current project I have.
Also I find the 7.3 explain harder to read. Never quite fully underestand
the 7.2 explain output, but 7.3 is even more informational/chatty.
Is there an "explain tutorial" somewhere? Specially covering the 7.3
details.
As an example of the query and explain output:
select jc.type, jc.id,
jc.last, jc.first,
jc.track, jc.date,
jc.race, jc.day,
ppl.carried_as, pe.jt_id
from jc_people jc, hraces hr,
rkeys rk, pplkeys ppl,
people pe
where jc.type = 'j' and
jc.track = rk.track and
jc.date = rk.date and
jc.race = rk.race and
hr.race_key = rk.race_key and
ppl.ppl_key = hr.jockey_key and
substring(ppl.carried_as from 1 for 3)
= substring(jc.last from 1 for 3) and
pe.type = 'j' and
ppl.type= 'j' and
pe.jt_id = 0 and
pe.ppl_key = ppl.ppl_key
limit 10;
Limit (cost=0.00..34349.28 rows=1 width=141)
-> Merge Join (cost=0.00..34349.28 rows=1 width=141)
Merge Cond: ("outer".ppl_key = "inner".jockey_key)
Join Filter: ("inner".race_key = "outer".race_key)
-> Nested Loop (cost=0.00..62872423.96 rows=5149 width=133)
Join Filter: ("outer".race = "inner".race)
-> Nested Loop (cost=0.00..62540586.27 rows=42980 width=116)
Join Filter: ("substring"(("outer".carried_as)::text, 1, 3) = "substring"(("inner".last)::text, 1, 3))
-> Nested Loop (cost=0.00..61156275.74 rows=1280 width=51)
Join Filter: ("outer".ppl_key = "inner".ppl_key)
-> Index Scan using people_pplkey on people pe (cost=0.00..2904.19 rows=6275 width=8)
Filter: ("type" = 'j'::bpchar)
-> Seq Scan on pplkeys ppl (cost=0.00..8929.70 rows=65324 width=43)
Filter: ("type" = 'j'::bpchar)
-> Seq Scan on jc_people jc (cost=0.00..963.96 rows=6716 width=65)
Filter: ("type" = 'j'::bpchar)
-> Index Scan using rk_track_date_eve_race on rkeys rk (cost=0.00..7.70 rows=1 width=17)
Index Cond: (("outer".track = rk.track) AND ("outer".date = rk.date))
-> Index Scan using hr_jockey_key on hraces hr (cost=0.00..26712.29 rows=492390 width=8)
From | Date | Subject | |
---|---|---|---|
Next Message | Giles Lean | 2003-02-03 21:39:03 | Re: Postgres server output logfile |
Previous Message | Mikael Carneholm | 2003-02-03 21:27:01 | Re: 335 times faster (!) |