Re: Index not being used unless enable_seqscan=false

From: Sven Willenberger <sven(at)dmv(dot)com>
To: Shane <shane-pgsql(at)cm(dot)nu>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Index not being used unless enable_seqscan=false
Date: 2005-08-10 20:24:51
Message-ID: 1123705491.1110.42.camel@lanshark.dmv.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, 2005-08-10 at 12:58 -0700, Shane wrote:
> On Wed, Aug 10, 2005 at 03:31:27PM -0400, Sven Willenberger wrote:
> > Right off the bat (if I am interpreting the results of your explain
> > analyze correctly) it looks like the planner is basing its decision to
> > seqscan as it thinks that it needs to filter over 1 million rows (versus
> > the 29,000 rows that actually are pulled). Perhaps increasing stats on
> > msgtime and then analyzing the table may help. Depending on your
> > hardware, decreasing random_page_cost in your postgresql.conf just a
> > touch may help too.
>
> Thanks for the pointers.
>
> I tried increasing the stats from the default of 10 to 25
> with no change. How high would you bring it? Also, I've
> never played with the various cost variables. The database
> sits on a raid5 partition composed of 4 15k u320 SCSI
> drives, dual xeon 2.8(ht enabled) 2gb ram. I suppose this
> might actually increase the cost of fetching a random disk
> page as it may well be on another physical disk and
> wouldn't be in the readahead cache. Any idea as to what it
> should be on this sort of system?
>
>
> ---------------------------(end of broadcast)---------------------------

Try increasing stats to 100 on just the msgtime column, not the default
(changing the default will only have an effect on newly created columns
-- you may want to change the default back to 10):

ALTER TABLE seen ALTER msgtime SET STATISTICS 100;

After running that command, analyze the table again and see if that
helps.

I am assuming the culprit is this particular column as your index and
search criteria is based on that one. The default random_page_cost I
believe is 4.0; on your system you could probably easily drop it to 3,
possibly lower, and see how that performs.

Sven

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Dan Armbrust 2005-08-10 20:31:07 Re: 5 new entries for FAQ
Previous Message SCassidy 2005-08-10 20:13:33 Re: accessing postgresql via odbc?