[elephant-devel] Backend and data retrieval questions

Alex Mizrahi killerstorm at newmail.ru
Tue Oct 21 20:37:17 UTC 2008


 RS> First, since I need to use multiple web application machines, I'm
 RS> using the Postmodern backend. I assume there's no sane way to share a
 RS> BDB db between multiple machines?

i think so too

 RS> Also, I want to do paginated data, so, for instance, I might, given an
 RS> object A with index B, want to display the first ten items matching B
 RS> = whatever. What's the recommended (ideally efficient) way to do this?

using cursor API. to get first ten items, first do cursor-pset, then 
cursor-pnext
9 times.

to get second ten items, you need to know OID of last object of a first 
batch,
(so you need to record it somewhere when you do first query). then
you call (cursor-get-both index whatever last-oid). that should place cursor
on last item of previous batch. then call cursor-pnext 10 times to get next
10 items.

and so on. if you want prev/next buttons, you just need to record oids
of first and last objects.

the only problem with pagination is that there is no efficient way
to calculate total amount of items,

this cursor stuff should work in theory, but i did not test it, so
if you have problems please notify me. or if it actually works
post a success story :)

 RS> How about searching via multiple indexes?

do you mean combining results of multiple queries into one
ordered (and paginated) list? this is also possible with cursor API,
but code will be somewhat hairy, i think.. 





More information about the elephant-devel mailing list