dbTalk Databases Forums  

(secondary) index-only scans

comp.databases.berkeley-db comp.databases.berkeley-db


Discuss (secondary) index-only scans in the comp.databases.berkeley-db forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Ryan
 
Posts: n/a

Default (secondary) index-only scans - 07-20-2006 , 03:32 PM






Hi,

How do you retrieve just the primary key from a secondary database,
without actually accessing the data associated with it? I want to
select a range of primary keys whose secondary keys fall in a given
interval, then sort those primary keys to improve locality before
accessing the actual records.

Quote:
From the documentation it looks like the only way to do that would be
to create the secondary database, close it, then reopen it without
associating so that BDB doesn't automatically follow the primary key to
the data. That seems like a bad approach, though, since the secondary
database would quickly go stale.

I searched this group and the Internet without any luck. Is BDB smart
enough to stay away from the primary table if I call Dbt::set_dlen(0)
on the data tuple first? I think the same question applies to
index-only scans in general (eg select <primary-key> from <table> where
<secondary-key> in <range>).

Thanks!



Reply With Quote
  #2  
Old   
Michael Cahill
 
Posts: n/a

Default Re: (secondary) index-only scans - 07-20-2006 , 07:31 PM






Hi Ryan,

Quote:
How do you retrieve just the primary key from a secondary database,
without actually accessing the data associated with it? I want to
select a range of primary keys whose secondary keys fall in a given
interval, then sort those primary keys to improve locality before
accessing the actual records.
The only way to avoid the primary lookup entirely is to open a handle
on the secondary database without associating it with the primary.
There is no need to close the secondary handle that is associated with
the primary, and there is no danger of the data going "stale" -- the
two handles will just have different views of the same underlying
database.

You will of course need to make sure that the databases are opened in
an environment that provides locking and a shared cache, but otherwise
this should be fairly straightforward.

Michael.



Reply With Quote
  #3  
Old   
Ryan
 
Posts: n/a

Default Re: (secondary) index-only scans - 07-21-2006 , 10:35 AM



Michael Cahill wrote:
Quote:
The only way to avoid the primary lookup entirely is to open a handle
on the secondary database without associating it with the primary.
There is no need to close the secondary handle that is associated with
the primary
That had not occured to me...
Thanks!



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.