rong.xian (AT) gmail (DOT) com wrote:
Quote:
Each key is an 4-byte integer and items
are some binary blocks around 40K to 60K Bytes.
I choose BTree as the accessing method. Pagesize was set to be 64KB
....
Because the key/item pair I searched is on some 'offpage'(overflow page)?
Does that mean when I finish get the smallest key, the second smallest
key was not loaded into cache? |
Yes. See http://www.sleepycat.com/docs/ref/am...bt_minkey.html
"This size is a function of the page size and the fact that at
least two key/data pairs must fit on any Btree page. Whenever key or
data items exceed the calculated size, they are stored on overflow
pages instead of in the standard Btree leaf pages."
IIRC, the default configuration is to move a record to an overflow page
if it is > 25% of the page size.
Quote:
Then does that mean btree's locality of reference doesn't work in that
case? why? |
Because BDB is page based, and with your record sizes, each key is on a
different page.
Quote:
Should I divide the key/item into some smaller block to enjoy locality
of reference? |
Yes. Or consider compressing them (e.g. with zlib) before storing
them. It is often the case that the cpu overhead of
compression/decompression is more than outweighed by the reduced IO
(better cache utilization).
Also, I believe that Sleepycat are considering allowing signficantly
larger pages than the current 64KB limit in a future release, which
would also solve your problem (without changing your record size). If
you are interested in that, I would suggest sending an email to
support (AT) sleepycat (DOT) com to request that feature (to make sure it stays on
the priority list).
regards,
Chris