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.


---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Reply via email to