pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: pginfo <pginfo@t1.unisoftbg.com>
To: Tomasz Myrta <jasiek@klaster.net>
Cc: pgsql-sql@postgresql.org <pgsql-sql@postgresql.org>
Subject: Re: Interest query plan
Date: Tue, 07 Oct 2003 17:14:59 +0200
Message-ID: <3F82D873.D6AD4C56@t1.unisoftbg.com> (raw)
References: <3F82D4FE.DD4E275B@t1.unisoftbg.com>
	<3F82E734.8060003@klaster.net>

 explain analyze select * from a_doc D left outer join A_SKLAD S
ON(D.IDS=S.IDS_DOC)  left join A_MED M ON(S.IDS_MED=M.IDS)  where
d.IDS='SOF_700060';
                                                               QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------------------

 Hash Join  (cost=1.26..80.55 rows=6 width=2091) (actual time=1.09..1.11
rows=1 loops=1)
   Hash Cond: ("outer".ids_med = "inner".ids)
   ->  Nested Loop  (cost=0.00..79.18 rows=6 width=2056) (actual
time=0.40..0.41 rows=1 loops=1)
         ->  Index Scan using a_doc_pkey on a_doc d  (cost=0.00..3.61 rows=1
width=1344) (actual time=0.14..0.14 rows=1 loops=1)
               Index Cond: (ids = 'SOF_700060'::name)
         ->  Index Scan using i_sklad_ids_doc on a_sklad s  (cost=0.00..75.31
rows=22 width=712) (actual time=0.12..0.13 rows=1 loops=1)
               Index Cond: ("outer".ids = s.ids_doc)
   ->  Hash  (cost=1.21..1.21 rows=21 width=35) (actual time=0.19..0.19
rows=0 loops=1)
         ->  Seq Scan on a_med m  (cost=0.00..1.21 rows=21 width=35) (actual
time=0.07..0.15 rows=21 loops=1)
 Total runtime: 1.82 msec
(10 rows)

I thinked that a_sklad join a_med ... will help, but....

Tomasz Myrta wrote:

> > Hi all,
> > I am running pg 7.3.1.
> > My query is very simple but pg generates not the best possible plan for
> > me:
> >  analyze select * from a_doc D left outer join (A_SKLAD S join A_MED M
> > ON(S.IDS_MED=M.IDS) )on( d.IDS=s.IDS_DOC)  where d.IDS='SOF_700060';
> What about:
>
> select * from a_doc D
>   left join A_SKLAD S on(d.IDS=s.IDS_DOC)
>   left join A_MED M ON(S.IDS_MED=M.IDS)
> where d.IDS='SOF_700060'
>
> ?
>
> Regards,
> Tomasz Myrta






view thread (5+ messages)  latest in thread

Message-ID: <3F82D873.D6AD4C56@t1.unisoftbg.com>
Permalink:  ../3F82D873.D6AD4C56@t1.unisoftbg.com/
Also on:    postgresql.org/message-id/3F82D873.D6AD4C56@t1.unisoftbg.com

 · 

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: pginfo@t1.unisoftbg.com, jasiek@klaster.net
  Subject: Re: Interest query plan
  In-Reply-To: <3F82D873.D6AD4C56@t1.unisoftbg.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