Re: Hash index todo list item

From: Kenneth Marshall <ktm(at)rice(dot)edu>
To: Mark Mielke <mark(at)mark(dot)mielke(dot)cc>
Cc: Neil Conway <neilc(at)samurai(dot)com>, pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: Hash index todo list item
Date: 2007-09-07 14:39:13
Message-ID: 20070907143913.GH19403@it.is.rice.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Sep 07, 2007 at 10:30:30AM -0400, Mark Mielke wrote:
> Kenneth Marshall wrote:
>> I understand that a hash value is a many-to-one mapping. That is the
>> point of the flag in the index. The flag means that there is only one
>> item in the heap corresponding to that hash value. In this case we
>> know that the value in the heap is the correct one and a possibly
>> very expensive string comparison can be skipped. Given that the hash
>> function is doing its job, almost every string comparison can be skipped.
>> How long would it take to compare 1-32K of data? How much CPU usage?
>> With this field in place, you only need to check tuple visibility
> The value comparison cannot be skipped. I do not think you understand the
> many-to-one mapping in its entirety.
>
> Example:
>
> Table has: a(1), b(2), c(3)
> Index has: 1 => 1 (unique), 2 => 2 (unique), 3 => 3 (unique)
>
> Query:
>
> select * from table where key = 'z';
>
> If 'z' hashes to '3' (completely possible), then the index record 3 points
> to tuple 3, and it "exists". Only, it doesn't because 'a' <> 'z'. You MUST
> check the value.
>
> Cheers,
> mark
>
Yes, you are completely correct. Thank you for the reminder.

Regards,
Ken

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message apoc9009 2007-09-07 14:41:25 Re: [FEATURE REQUEST] Streaming Onlinebackup (Maybe OFFTOPIC)
Previous Message Brian Hurt 2007-09-07 14:36:41 Re: Hash index todo list item