From: Tom Lane <tgl@sss.pgh.pa.us>
To: sarlav kumar <sarlavk@yahoo.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: help needed -- sequential scan problem
Date: Sat, 20 Nov 2004 00:19:46 -0500
Message-ID: <16679.1100927986@sss.pgh.pa.us> (raw)
In-Reply-To: <20041119223122.49470.qmail@web51301.mail.yahoo.com>
References: <20041119223122.49470.qmail@web51301.mail.yahoo.com>
sarlav kumar <sarlavk@yahoo.com> writes:
> I have a query which does not use index scan unless I force postgres to use index scan. I dont want to force postgres, unless there is no way of optimizing this query.
The major issue seems to be in the sub-selects:
> -> Seq Scan on merchant_purchase mp (cost=0.00..95.39 rows=44 width=4) (actual time=2.37..2.58 rows=6 loops=619)
> Filter: (merchant_id = $0)
where the estimated row count is a factor of 7 too high. If the
estimated row count were even a little lower, it'd probably have gone
for an indexscan. You might get some results from increasing the
statistics target for merchant_purchase.merchant_id. If that doesn't
help, I'd think about reducing random_page_cost a little bit.
regards, tom lane
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, sarlavk@yahoo.com
Subject: Re: help needed -- sequential scan problem
In-Reply-To: <16679.1100927986@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