You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Mark Hahn <ma...@hahnca.com> on 2012/07/24 01:23:26 UTC
random access to log db
I have a log db that I am only adding new docs to. I am never updating,
deleting, or compacting any docs.
I'd like to show these docs in a table on the client-side. The table
software will ask for ranges of docs like 200 to 300, assuming sequential
id numbers.
Is it correct that this cannot be done with normal couchdb queries? How
would you deal with this situation?
Re: random access to log db
Posted by Keith Gable <zi...@ignition-project.com>.
This could be done with CouchDB. You need a view that emits the ID and then
?startkey=200&endkey=299 on the view. Add include_docs=true if you want the
log doc too.
Not sure how you guarantee the numbers will increase atomically though.
On Jul 23, 2012 6:24 PM, "Mark Hahn" <ma...@hahnca.com> wrote:
> I have a log db that I am only adding new docs to. I am never updating,
> deleting, or compacting any docs.
>
> I'd like to show these docs in a table on the client-side. The table
> software will ask for ranges of docs like 200 to 300, assuming sequential
> id numbers.
>
> Is it correct that this cannot be done with normal couchdb queries? How
> would you deal with this situation?
>
Re: random access to log db
Posted by Mark Hahn <ma...@hahnca.com>.
Thanks everyone for the ideas. I've got some thinking to do.
On Mon, Jul 23, 2012 at 7:27 PM, Jens Alfke <je...@couchbase.com> wrote:
>
> On Jul 23, 2012, at 4:23 PM, Mark Hahn <ma...@hahnca.com> wrote:
>
> > I have a log db that I am only adding new docs to. I am never updating,
> > deleting, or compacting any docs.
> >
> > I'd like to show these docs in a table on the client-side. The table
> > software will ask for ranges of docs like 200 to 300, assuming sequential
> > id numbers.
>
> Sounds like a job for the _changes feed.
>
> —Jens
Re: random access to log db
Posted by Jens Alfke <je...@couchbase.com>.
On Jul 23, 2012, at 4:23 PM, Mark Hahn <ma...@hahnca.com> wrote:
> I have a log db that I am only adding new docs to. I am never updating,
> deleting, or compacting any docs.
>
> I'd like to show these docs in a table on the client-side. The table
> software will ask for ranges of docs like 200 to 300, assuming sequential
> id numbers.
Sounds like a job for the _changes feed.
—Jens
Re: random access to log db
Posted by Matthieu Rakotojaona <ma...@gmail.com>.
On Tue, Jul 24, 2012 at 1:23 AM, Mark Hahn <ma...@hahnca.com> wrote:
> How would you deal with this situation?
I see a few possible solutions, but none is really satisfactory :
* If you are 100% sure that you will never update/delete any doc, you
could include the db's update_seq in a document. However, there is no
mean to modify a doc on server upon POST/PUTing it. So it would
require two calls, and you are not guaranteed that someone else is not
modifying the db at the same moment
* You could do the same with db's size, but you will have the same
problem of atomicity
* You could use `algorithm=utc_random` for generating uuids, which
would give you sequential uuids. However, this setting is server-wide,
not database-wide.
All in all, I don't see a solution that wouldn't involve a 2-step
POST/PUT. Unless there is some way to modify a doc server-side when
you add it to the store, which could be really handy.
--
Matthieu RAKOTOJAONA