Re: Query not using the index

From: Andrew Sullivan <andrew(at)libertyrms(dot)info>
To: pgsql-performance(at)postgresql(dot)org
Subject: Re: Query not using the index
Date: 2003-02-25 12:44:50
Message-ID: 20030225074450.A16284@mail.libertyrms.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Tue, Feb 25, 2003 at 07:03:40PM +1100, Mark Halliwell wrote:

> The majority of records (about 6.8 million) have computer = 8 with sequence
> starting at 2200000 and incrementing by 1.
> There are about 497000 records with computer = 3 with the sequence starting at
> 1 and also incrementing by 1.
> There are only a few records with other computer numbers.

> select * from replicate where computer = 3 and sequence >= 490000;
>
> I have created several different indexes (always doing a vacuum analyse
> afterwards etc), but the explain always reports a sequential scan. If I

Try setting the statistics on computer to a much wider value -- say

ALTER TABLE computer ALTER COLUMN computer SET STATISTICS 1000

and see if it helps. You can poke around in the pg_stats view to see
why this might help, and perhaps to get a more realistic idea of what
you need to set the statistics to. The problem is likely the
overwhelming commonality of computer=8.

A

--
----
Andrew Sullivan 204-4141 Yonge Street
Liberty RMS Toronto, Ontario Canada
<andrew(at)libertyrms(dot)info> M2P 2A8
+1 416 646 3304 x110

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Bruno Wolff III 2003-02-25 13:56:29 Re: Query not using the index
Previous Message Mark Halliwell 2003-02-25 08:03:40 Query not using the index