|
|
|
|
|
|
| Author |
Message |
Ryan *nix forums beginner
Joined: 20 Jul 2006
Posts: 1
|
Posted: Thu Jul 20, 2006 8:32 pm Post subject:
(secondary) index-only scans
|
|
|
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
|
Posted: Fri Jul 21, 2006 12:31 am Post subject:
Re: (secondary) index-only scans
|
|
|
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 |
|
 |
|
|
The time now is Mon Dec 01, 2008 9:10 pm | All times are GMT
|
|
Credit Cards | Internet Advertising | Mobile Phones | Loan | Cheap mp3 players
|
|
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
|
|