couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ganzha Alexey <tret...@gmail.com>
Subject Re: 1 large view vs 2 smaller views
Date Sun, 24 Jul 2011 22:24:44 GMT
Thanks for your answer.

Actually it is very important to sort by the other fields: dep, price. even
_id i need to separate docs with the same price.
So, the only way i see - this additional "week" (''THIS_IS_FOR_ALL'',
'THIS_IS_FOR_LAST_WEEK_
ONLY') element in the key, at the first place. And i have to match this
element exactly for all docs, or for week docs.


On Mon, Jul 25, 2011 at 12:54 AM, Dennis Clark <dbfclark@gmail.com> wrote:

> How important is it to you to have the view sorted by doc.dep? If the
> answer
> is "not at all," the idiomatically CouchDB way to do this is:
>
> emit(doc.date,[doc.dep,doc.price,doc._id]);
>
> and then let users query with startkey/endkey if they need only the docs
> from the last week. This way you don't need some "in the last week" field
> that you have to keep updated.
>
> On Sun, Jul 24, 2011 at 5:46 PM, Ganzha Alexey <tretiy3@gmail.com> wrote:
>
> > Hi.
> > I am trying figuring out whats the better.
> >
> > Say i have a view:
> > ...
> >    emit([doc.dep,doc.price,doc.date,doc._id]);
> > ...
> >
> > Some users need all docs. And some of them need only docs for the last
> > week.
> > Just add an attribute 'last_week' in required documents.
> > Then, in the view i will check this attribute and there are 2 cases:
> >
> > Filter docs in 1 view
> >
> > emit(['THIS_IS_FOR_ALL',doc.dep,doc.price,doc.date,doc._id]);
> >
> > if (doc.last_week)
> >
> emit(['THIS_IS_FOR_LAST_WEEK_ONLY',doc.dep,doc.price,doc.date,doc._id]);
> >
> > i will be able to query this view with the additional key member (will
> user
> > need all docs, or only last week docs)
> >
> > Or make 2 separate views. First:
> >
> > emit([doc.dep,doc.price,doc.date,'doc._id]);
> >
> > and  Second:
> >
> > if (doc.last_week)
> >    emit([doc.dep,doc.price,doc.date,doc._id])
> >
> > First case will emit more keys, and the keys will be larger by 1 element.
> > But in second case, there are 2 views.
> >
> > What would you prefer. What is the better for performance?
> > Thanks
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message