pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Jean-Max Reymond <jmreymond@gmail.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Optimizing a request
Date: Tue, 31 Aug 2004 16:13:58 -0400
Message-ID: <14630.1093983238@sss.pgh.pa.us> (raw)
In-Reply-To: <4b09a0c0408311159fa91802@mail.gmail.com>
References: <4b09a0c0408311159fa91802@mail.gmail.com>

Jean-Max Reymond <jmreymond@gmail.com> writes:
> explain SELECT art_id, art_titre, art_texte, rub_titre
> FROM article inner join rubrique on article.rub_id = rubrique.rub_id
> where rub_parent = 8;

> Hash Join  (cost=8.27..265637.59 rows=25 width=130)
>   Hash Cond: ("outer".rub_id = "inner".rub_id)
>   ->  Seq Scan on article  (cost=0.00..215629.00 rows=10000000 width=108)
>   ->  Hash  (cost=8.26..8.26 rows=3 width=22)
>         ->  Index Scan using rubrique_parent on rubrique 
> (cost=0.00..8.26 rows=3 width=22)
>               Index Cond: (rub_parent = 8)

That seems like a very strange plan choice given those estimated row
counts.  I'd have expected it to use a nestloop with inner index scan
on article_rub_id_index.  You haven't done anything odd like disable
nestloop, have you?

What plan do you get if you turn off enable_hashjoin?  (If it's a merge
join, then turn off enable_mergejoin and try again.)  Also, could we see
EXPLAIN ANALYZE not just EXPLAIN output for all these cases?

			regards, tom lane



view thread (11+ messages)  latest in thread

Message-ID: <14630.1093983238@sss.pgh.pa.us>
Permalink:  ../14630.1093983238@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/14630.1093983238@sss.pgh.pa.us

 · 

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-performance@postgresql.org
  Cc: tgl@sss.pgh.pa.us, jmreymond@gmail.com
  Subject: Re: Optimizing a request
  In-Reply-To: <14630.1093983238@sss.pgh.pa.us>

* 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