database - BDB, How to get primary keys in specified order? -


i have asked same question days on oracle forums, no answer came:( link is:http://forums.oracle.com/forums/thread.jspa?threadid=2162345&tstart=0

hi, build bbs using bdb backend database, forum database, topic database , post database share 1 environment. bbs web application multi-thread program. if user selects 1 forum, topics listed in order of last reply time;selecting 1 topic, posts listed in order of reply time well.

struct forum { uint16 forumid; string forumname; string _lastposter; // last 1 replied in forum };  struct topic { uint32 topicid; uint16 forumid; // topic comes forum string title; // topic title uint64 dateoflastreply; // when last reply topic happen };  struct post { uint64 postid; uint32 topicid; // post comes topic string title; // post title of topic uint64 dateofpost; // when post created }; 

i create 1 primary database , 2 secondary databases topic, primary key topicid, secondary keys forumid , dateoflastreply respectively, , want show 1st 25 topics in latest reply time order on 1st browser page, 2nd 25 topics on 2nd browser page, , etc.

if using sql, be: select topicid from topic where forumid=xx order by dateoflastreply desc

from performance perspective, want topics id of 1 same forum, , need them come in reply time order, retrieve topic 1 one based on returned topicid, how can this? guess have use joins. plus, have suggestion retrieval performance given fact topics retrieval happen each time browser want request next page, is, 2nd 25 topics of forum? db_dbt_multiple helpful me?

thanks.

you need create secondary database composite key, consisting of (forum_id, dateoflastreply). then, results want in contiguous range of rows, , can query on them doing range scan (eg, 20 rows starting (1, 2010-01-01)).


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -