From: | Mark Mielke <mark(at)mark(dot)mielke(dot)cc> |
---|---|
To: | Kenneth Marshall <ktm(at)rice(dot)edu> |
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:30:30 |
Message-ID: | 46E16086.1010007@mark.mielke.cc |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
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
--
Mark Mielke <mark(at)mielke(dot)cc>
From | Date | Subject | |
---|---|---|---|
Next Message | Brian Hurt | 2007-09-07 14:36:41 | Re: Hash index todo list item |
Previous Message | Filip Rembiałkowski | 2007-09-07 14:23:37 | Re: [FEATURE REQUEST] Streaming Onlinebackup (Maybe OFFTOPIC) |