From: Adam Gundy <adam@starsilk.net>
To: Richard Huxton <dev@archonet.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: varchar index joins not working?
Date: Thu, 10 Apr 2008 12:54:25 -0600
Message-ID: <6f55f1270804101154t3d4a01eco2b7bff7a0053af38@mail.gmail.com> (raw)
In-Reply-To: <47FE29AF.6010906@starsilk.net>
References: <6f55f1270804092013n73ee1f81t2c6d72cee49655a3@mail.gmail.com>
<47FDD3D1.9070208@archonet.com>
<47FE29AF.6010906@starsilk.net>
On Thu, Apr 10, 2008 at 8:52 AM, Adam Gundy <adam@starsilk.net> wrote:
> Richard Huxton wrote:
> > How many distinct values do you have in groups.groupid and
> group_access.group_id?
> >
>
> for the small database (since it shows the same problem):
>
> group_access: 280/268
> groups: 2006/139
>
> for the large database:
>
> group_access: same
> groups: 1712647/140
>
> the groupid key is an MD5 hash, so it should be uniformly distributed.
> maybe that throws the stats? but, again, char works, varchar doesn't :-(
OK, I'm thinking the varchar/char part is not the issue.
the database is very unbalanced, most of the groups are 1000 or less
records, with one group occupying 95% of the records.
I *think* that when I analyze using char instead of varchar, it is
recording a stat for the large group, but for some reason with varchar
doesn't add a stat for that one.
so, the real question is, how do I fix this? I can turn the stats way
up to 1000, but that doesn't guarantee that I'll get a stat for the
large group :-(
can I turn the statistics off completely for this column? I'm guessing
that if I can, that will mean it takes a guess based on the number of
distinct values in the groups table, which is still large number of
records, possibly enough to trigger the seqscan anyway.
does postgres have a way of building a 'counted index' that the
planner can use for it's record counts? some way of forcibly
maintaining a stat for every group?
the groups are not related to one another - is it possible to
partition them into their own indexes somehow?
ahh. lots of questions, no (obvious to me) answers from googling around.
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-performance@postgresql.org
Cc: adam@starsilk.net, dev@archonet.com
Subject: Re: varchar index joins not working?
In-Reply-To: <6f55f1270804101154t3d4a01eco2b7bff7a0053af38@mail.gmail.com>
References: <6f55f1270804092013n73ee1f81t2c6d72cee49655a3@mail.gmail.com> <47FDD3D1.9070208@archonet.com> <47FE29AF.6010906@starsilk.net> <6f55f1270804101154t3d4a01eco2b7bff7a0053af38@mail.gmail.com>
* 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