pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tomasz Myrta <jasiek@klaster.net>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Lista dyskusyjna pgsql-sql <pgsql-sql@postgresql.org>
Subject: Re: explicit joins wrong planning
Date: Fri, 28 Nov 2003 20:43:33 +0100
Message-ID: <3FC7A565.4000104@klaster.net> (raw)
In-Reply-To: <29784.1070047126@sss.pgh.pa.us>
References: <3FC63057.3080009@klaster.net>
	<29784.1070047126@sss.pgh.pa.us>

Dnia 2003-11-28 20:18, Użytkownik Tom Lane napisał:
> Hard to say much when you didn't actually show us the output of EXPLAIN
> ANALYZE.

OK, Here you are:

explain analyze select *
from plany pl
   join linia_trasy lt using (id_linii)
   join kursy k on (k.id_trasy=lt.id_trasy and 
k.event_date=pl.begindate+lt.offset)
where pl.id_planu=508;

event_date - date
begindate - date
id_linii - integer
id_trasy - integer
offset - integer

                                                               QUERY PLAN
--------------------------------------------------------------------------------------------------------------------------------------
  Hash Join  (cost=5.82..1210.68 rows=2 width=40) (actual 
time=718.11..759.27 rows=5 loops=1)
    Hash Cond: ("outer".id_trasy = "inner".id_trasy)
    Join Filter: ("outer".event_date = ("inner".begindate + "inner".offset))
    ->  Seq Scan on kursy k  (cost=0.00..876.07 rows=58707 width=11) 
(actual time=0.02..547.65 rows=58707 loops=1)
    ->  Hash  (cost=5.81..5.81 rows=7 width=29) (actual time=0.43..0.43 
rows=0 loops=1)
          ->  Nested Loop  (cost=0.00..5.81 rows=7 width=29) (actual 
time=0.16..0.37 rows=7 loops=1)
                Join Filter: ("outer".id_linii = "inner".id_linii)
                ->  Index Scan using plany_pkey on plany pl 
(cost=0.00..4.49 rows=1 width=17) (actual time=0.09..0.11 rows=1 loops=1)
                      Index Cond: (id_planu = 508)
                ->  Seq Scan on linia_trasy lt  (cost=0.00..1.14 rows=14 
width=12) (actual time=0.02..0.12 rows=14 loops=1)


If I add "and k.id_trasy=lt.id_trasy" into where clause (duplicate), the 
query works fine.

Regards,
Tomasz Myrta




view thread (7+ messages)  latest in thread

Message-ID: <3FC7A565.4000104@klaster.net>
Permalink:  ../3FC7A565.4000104@klaster.net/
Also on:    postgresql.org/message-id/3FC7A565.4000104@klaster.net

 · 

reply

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-sql@postgresql.org
  Cc: jasiek@klaster.net, tgl@sss.pgh.pa.us
  Subject: Re: explicit joins wrong planning
  In-Reply-To: <3FC7A565.4000104@klaster.net>

* 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