pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Pallav Kalva <pkalva@livedatagroup.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: 8.2.4 Chooses Bad Query Plan
Date: Tue, 28 Aug 2007 17:06:12 -0400
Message-ID: <3926.1188335172@sss.pgh.pa.us> (raw)
In-Reply-To: <46D4777B.5030701@livedatagroup.com>
References: <46D43A8C.2080201@livedatagroup.com>
	<1206.1188326173@sss.pgh.pa.us>
	<46D4777B.5030701@livedatagroup.com>

Pallav Kalva <pkalva@livedatagroup.com> writes:
> I have analyzed tables again and also my default_stats_target is set to
> 100, still it shows the same plan.

>>> ->  Index Scan using idx_accountactivity_fkactivityid on
>>> accountactivity accountact0_  (cost=0.00..3.94 rows=1 width=16)
>>> Index Cond: (accountact0_.fkactivityid =
>>> activity1_.activityid)
>>> Filter: (fkaccountid = 1455437)

>>> ->  Index Scan using
>>> idx_accountactivity_fkaccountid on accountactivity accountact0_ 
>>> (cost=0.00..1641.42 rows=1343 width=16) (actual time=115.348..864.416
>>> rows=10302 loops=1)
>>> Index Cond: (fkaccountid = 1455437)

Oh, my bad, I failed to look closely enough at these subplans.
I thought they were identical but they're not using the same scan
conditions, so the rowcount estimates shouldn't be comparable after all.

Could you try EXPLAINing (maybe even with ANALYZE) the query *without*
the LIMIT clause?  I'm curious to see what it thinks the best plan is
then.

			regards, tom lane



view thread (4+ messages)

Message-ID: <3926.1188335172@sss.pgh.pa.us>
Permalink:  ../3926.1188335172@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/3926.1188335172@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, pkalva@livedatagroup.com
  Subject: Re: 8.2.4 Chooses Bad Query Plan
  In-Reply-To: <3926.1188335172@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