niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » Databases » Berkeley DB
(secondary) index-only scans
Post new topic   Reply to topic Page 1 of 1 [2 Posts] View previous topic :: View next topic
Author Message
Ryan
*nix forums beginner


Joined: 20 Jul 2006
Posts: 1

PostPosted: Thu Jul 20, 2006 8:32 pm    Post subject: (secondary) index-only scans Reply with quote

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!
Back to top
Michael Cahill
*nix forums Guru Wannabe


Joined: 26 May 2005
Posts: 219

PostPosted: Fri Jul 21, 2006 12:31 am    Post subject: Re: (secondary) index-only scans Reply with quote

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.
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [2 Posts] View previous topic :: View next topic
The time now is Mon Dec 01, 2008 9:07 pm | All times are GMT
navigation Forum index » Databases » Berkeley DB
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts Secondary db empty susu Berkeley DB 0 Thu Sep 21, 2006 10:37 am
No new posts container for insert/delete + fast index Neal Becker C++ 1 Fri Jul 21, 2006 12:57 pm
No new posts Create index hanging Claire McLister PostgreSQL 7 Thu Jul 20, 2006 8:11 pm
No new posts VACUUM and index DANTE Alexandra PostgreSQL 3 Wed Jul 19, 2006 1:03 pm
No new posts number of distinct values in tsearch2 gist index Kevin Murphy PostgreSQL 0 Tue Jul 18, 2006 5:24 pm

Free phpBB forum | Loan | Credit Card Debt Consolidation | Electricity Suppliers | Online Advertising
Copyright © 2004-2005 DeniX Solutions SRL
 
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum | 
Privacy Policy


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1777s ][ Queries: 16 (0.0785s) ][ GZIP on - Debug on ]