Re: select distinct and index usage

From: "David Wilson" <david(dot)t(dot)wilson(at)gmail(dot)com>
To: "Craig Ringer" <craig(at)postnewspapers(dot)com(dot)au>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: select distinct and index usage
Date: 2008-04-07 02:41:56
Message-ID: e7f9235d0804061941r16ccd94cjcc41d26e8bde93dd@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Both tables are vacuumed and analyzed. I have other queries that are
using various indices on the vals table in an intelligent fashion. I
can try increasing the stats, certainly, although they're at the
defaults for both tables.

The variation is definitely identical- the set of datestamps in the
vals table is a large (~98%) subset of the set of datestamps in the
sdays table. Of the approximately 4000 distinct datestamps, there are
80 that appear in the sdays table and not in the vals table.

On Sun, Apr 6, 2008 at 10:20 PM, Craig Ringer
<craig(at)postnewspapers(dot)com(dot)au> wrote:
> David Wilson wrote:
>
> > On another table in the same database with a much smaller number of
> > total rows (~15m rows), I have the exact same situation- but in this
> > case the index on the datestamp column *is* used:
> >
> >
> Have you run ANALYZE on both tables?
>
> It might be worth increasing the stats collected on the datestamp column
> (or all columns in the table), re-running ANALYZE on the table, and seeing
> what happens.
>
> Also, is there any chance that that's a lot more variation in datestamp
> values in your problem table than the one where the index is used?
>
> --
> Craig Ringer
>

--
- David T. Wilson
Princeton Satellite Systems
david(dot)t(dot)wilson(at)gmail(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tim Uckun 2008-04-07 04:10:06 calendar best practices for postgres
Previous Message Craig Ringer 2008-04-07 02:20:15 Re: select distinct and index usage