Re: why hash on the primary key?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Robert Haas" <robertmhaas(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: why hash on the primary key?
Date: 2008-11-28 20:16:36
Message-ID: 140.1227903396@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Robert Haas" <robertmhaas(at)gmail(dot)com> writes:
> It seems very strange for the planner to decide to build an in-memory
> hash table on a column that is already indexed (the primary key, no
> less!).

What's strange about it? A probe into an in-memory hashtable is a lot
cheaper than a probe into an index, so this type of plan makes plenty
of sense if the hashtable will fit in RAM and there are going to be a
lot of probes. (Where "a lot" means "enough to amortize the cost of
building the hashtable", of course.)

> Experimentation shows this is actually about 25% faster.

Well, that just says your cost parameters need a bit of adjustment
if you'd like the planner to get the crossover point exactly right.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Willy-Bas Loos 2008-11-28 21:20:20 Re: Separate Sessions?? (View data <-> Query tool)
Previous Message Adam Rich 2008-11-28 20:04:58 Re: why hash on the primary key?