Re: Hash index todo list item - Mailing list pgsql-hackers

From Gokulakannan Somasundaram
Subject Re: Hash index todo list item
Date
Msg-id 9362e74e0711060027h3fd1370eu3d060b579a01b18f@mail.gmail.com
Whole thread Raw
In response to Re: Hash index todo list item  (Shreya Bhargava <shreya_bhargav@yahoo.com>)
List pgsql-hackers
I have not followed this thread very closely. But just wanted to give my inputs.


> From the results obtained, the average of all the hash probes is 141.8ms,
> the average for btree is 168.5, a difference of about 27.The standard
> deviations are about 23, so this is a statistically significant difference.
> Our prediction that the hash index would take on the average one
> probe for about 10ms and the btree would take three probes for about 30 ms
> or a difference of about 20ms was pretty well shown by the difference we
> got of about 27. Hope these data points will help with some questions
> about the performance differences between Hash and Btree index.
>

We all know that Hash indexes are good for equality queries and Binary
indexes are good for both equality queries and Range queries. So for
equality queries, Hash index should do only one Logical I/O (if no
hash collisions) and Binary index should do atleast 3 (I don't know
the level of B-tree that came out as a result of this). You can enable
the Logical I/O count by applying this patch.

*** postgresql-8.3beta1/src/backend/storage/buffer/bufmgr.c    Tue Sep 25
18:11:48 2007
--- postgresql-8.3patch/src/backend/storage/buffer/bufmgr.c    Fri Oct 19
23:18:36 2007
***************
*** 1470,1477 ****         localhitrate = (float) LocalBufferHitCount *100.0 / ReadLocalBufferCount;
     appendStringInfo(&str,
!     "!\tShared blocks: %10ld read, %10ld written, buffer hit rate = %.2f%%\n",
!                 ReadBufferCount - BufferHitCount, BufferFlushCount, hitrate);     appendStringInfo(&str,
"!\tLocal blocks: %10ld read, %10ld written, buffer hit rate = %.2f%%\n",                      ReadLocalBufferCount -
LocalBufferHitCount,
LocalBufferFlushCount, localhitrate);
--- 1470,1477 ----         localhitrate = (float) LocalBufferHitCount *100.0 / ReadLocalBufferCount;
     appendStringInfo(&str,
!     "!\tShared blocks: %10ld Logical Reads, %10ld Physical Reads, %10ld
written, buffer hit rate = %.2f%%\n",
!                 ReadBufferCount, ReadBufferCount - BufferHitCount,
BufferFlushCount, hitrate);     appendStringInfo(&str,     "!\tLocal  blocks: %10ld read, %10ld written, buffer hit
rate= %.2f%%\n",                      ReadLocalBufferCount - LocalBufferHitCount,
 
LocalBufferFlushCount, localhitrate);


If possible, it would be useful for you to present the reduction in
Logical I/O count, as it very well might translate to Physical I/Os
for simple index scans. Atleast check whether it is in the ratio 1:3.

Hope my suggestion helps.


Thanks,
Gokul.
CertoSQL Project,
Allied Solution Group.
(www.alliedgroups.com)


pgsql-hackers by date:

Previous
From: "Gokulakannan Somasundaram"
Date:
Subject: Re: Visibility map thoughts
Next
From: Heikki Linnakangas
Date:
Subject: Re: Hash index todo list item