pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Heikki Linnakangas <heikki@enterprisedb.com>
To: Kynn Jones <kynnjo@gmail.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Joins and DELETE FROM
Date: Sat, 08 Mar 2008 20:25:09 +0000
Message-ID: <47D2F625.4050700@enterprisedb.com> (raw)
In-Reply-To: <c2350ba40803081102v14d7c3f0u349fb361351fec5a@mail.gmail.com>
References: <c2350ba40803080931y363d6fd9oaaca11a0ea4f1b79@mail.gmail.com>
	<47D2D485.9040103@enterprisedb.com>
	<c2350ba40803081102v14d7c3f0u349fb361351fec5a@mail.gmail.com>

Kynn Jones wrote:
> my_db=> SET ENABLE_SEQSCAN TO OFF;
> my_db=> EXPLAIN ANALYZE SELECT * FROM T NATURAL JOIN B;
>                                                               QUERY PLAN
> ---------------------------------------------------------------------------------------------------------------------------------------
>  Merge Join  (cost=0.00..423589.69 rows=219784 width=13) (actual time=
> 0.114..5449.808 rows=219784 loops=1)
>    Merge Cond: (t.k = b.k)
>    ->  Index Scan using idx__t on t  (cost=0.00..386463.71 rows=10509456
> width=13) (actual time=0.059..3083.182 rows=10509414 loops=1)
>    ->  Index Scan using idx__b on b  (cost=0.00..8105.04 rows=219784
> width=12) (actual time=0.044..69.659 rows=219784 loops=1)
>  Total runtime: 5473.812 ms
> (5 rows)

That's more like 2% of the rows, not 0.1%.

Note that this still isn't the plan you were asking for, it's still 
scanning the whole index for t, not just looking up the keys from b. 
What you wanted is a nested loop join. You could try to turn 
enable_mergejoin=off as well if you want to coerce the planner even more...

-- 
   Heikki Linnakangas
   EnterpriseDB   http://www.enterprisedb.com



view thread (6+ messages)  latest in thread

Message-ID: <47D2F625.4050700@enterprisedb.com>
Permalink:  ../47D2F625.4050700@enterprisedb.com/
Also on:    postgresql.org/message-id/47D2F625.4050700@enterprisedb.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-performance@postgresql.org
  Cc: heikki@enterprisedb.com, kynnjo@gmail.com
  Subject: Re: Joins and DELETE FROM
  In-Reply-To: <47D2F625.4050700@enterprisedb.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