From: Tom Lane <tgl@sss.pgh.pa.us>
To: Kevin McArthur <Kevin@StormTide.ca>
Cc: pgsql-performance@postgresql.org
Subject: Re: Bad Planner Statistics for Uneven distribution.
Date: Fri, 21 Jul 2006 17:29:53 -0400
Message-ID: <8073.1153517393@sss.pgh.pa.us> (raw)
In-Reply-To: <003b01c6acf1$a66d8910$0701a8c0@kdesktop>
References: <003b01c6acf1$a66d8910$0701a8c0@kdesktop>
"Kevin McArthur" <Kevin@StormTide.ca> writes:
> -> Seq Scan on models_brands (cost=0.00..6411.89 rows=369489 width=4) (actual time=0.040..1352.997 rows=369489 loops=1)
> ...
> -> Index Scan using models_brands_brand on models_brands (cost=0.00..862236.96 rows=369489 width=4) (actual time=0.122..1440.809 rows=369489 loops=1)
> Picks the wrong plan here. Should pick the index with seqscanning enabled.
It's really not possible for a full-table indexscan to be faster than a
seqscan, and not very credible for it even to be approximately as fast.
I suspect your second query here is the beneficiary of the first query
having fetched all the pages into cache. In general, if you want to
optimize for a mostly-cached database, you need to reduce
random_page_cost below its default value ...
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, Kevin@StormTide.ca
Subject: Re: Bad Planner Statistics for Uneven distribution.
In-Reply-To: <8073.1153517393@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