dbTalk Databases Forums  

Re: Best way for inequality join?

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


Discuss Re: Best way for inequality join? in the comp.databases.berkeley-db forum.



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

Default Re: Best way for inequality join? - 08-31-2003 , 02:40 PM






I think that rather than use a join, you should set up the b-tree
expressing the function as a secondary index. see:
http://www.sleepycat.com/docs/ref/am/second.html
http://www.sleepycat.com/docs/api_cxx/db_associate.html

If there is some other criteria that you need to check in addition,
that has a different index, then you would use the join functionality.

You can set up the callback function to calculate the expression
and store the result in the secondary index. It would be best to
define your own comparison function as the default is to do a byte
wise comparison, which will work on some architectures but not
others.

Michael Ubell
Sleepycat Software.



Reply With Quote
  #2  
Old   
Mark Fletcher
 
Posts: n/a

Default Re: Best way for inequality join? - 08-31-2003 , 10:35 PM






Michael Ubell <ubell (AT) sleepycat (DOT) com> wrote

Quote:
I think that rather than use a join, you should set up the b-tree
expressing the function as a secondary index. see:
http://www.sleepycat.com/docs/ref/am/second.html
http://www.sleepycat.com/docs/api_cxx/db_associate.html

Thanks for the response. Looking back, I didn't fully describe what I
was trying to accomplish. Here it is.

I have a set of objects in a queue, each object represents information
about a site (each site can have many such objects). There are two
b-tree indexes to those objects, both of which reference queue ids.
One index is of site ids, the other is essentially a version counter.
I want to count the number of objects with a particular site id that
have a version number > than a particular number, where the particular
number can vary by query. So I need join functionality, but not a
normal equality join.

The b-tree containing version numbers was created with a special
comparision function, to sort numerically by version number. But a
normal join using these indexes against the queue only returns exact
matches with the version number. Even when I initialize the cursor for
the version index with DB_SET_RANGE it does this.

Do I need to re-create the join functionality for non-equality joins?
Or am I doing something boneheaded (more likely).

Thanks,

Mark


Reply With Quote
  #3  
Old   
Michael Ubell
 
Posts: n/a

Default Re: Best way for inequality join? - 09-03-2003 , 12:52 PM



Mark Fletcher wrote:

Quote:
The b-tree containing version numbers was created with a special
comparision function, to sort numerically by version number. But a
normal join using these indexes against the queue only returns exact
matches with the version number. Even when I initialize the cursor for
the version index with DB_SET_RANGE it does this.

Do I need to re-create the join functionality for non-equality joins?
Or am I doing something boneheaded (more likely).

The join functionality only supports equality, sorry. You will have to
impliment the functionality yourself, I think.

Michael Ubell
Sleepycat Software.



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.