On 4/07/2011 1:11 PM, Matthew John wrote:
Hi all,
I am a newbie at CouchDB. I had a few queries back in my mind and thought I
would shoot them here:
1) I am familiar with MySql systems. In one of the applications I ve made,
whenever the server gets restarted I used to perform a warm up (similar to
Select * from *) inorder to populate the cache. And this used to take almost
like half an hour. How does it happen in CuuchDB and how long might it take
for the "warm up"
Views are stored on disk, and will persist across server restarts.
2) I understand that all the MR queries (views) to be used in the system has
to be coded in the Design document. Does that mean a super-set of all
possible queries which we might use in the System has to be coded in the
Design doc? Can this be added on the fly (dynamic )
Dynamically added, or 'temporary' views are really only meant for
testing, and on small datasets. Don't use them.
Views are defined in the design document beforehand, yes, but a single
couchdb view is much more flexible and customisable than an SQL query.
For instance, you could have a view that emits a values with a key like
[country,state,city], and has a reduce of _count.
Then you could:
* Fetch all values from a single country.
startkey=[country],endkey=[country,{}]
* Fetch all values from a single state.
startkey=[country,state],endkey=[country,state,{}]
* Fetch all values from american states A-L.
startkey=["USA","A"],endkey=["USA","Lzzzz"]
* Fetch total count of rows; reduce=true
* Fetch total count of rows, grouped by country,state,city;
reduce=true,group=true
* Fetch total count of rows, grouped by country,state;
reduce=true,group=true,grouplevel=2
It may require some re-thinking of your data model and queries to get
the best solution working in couchdb, but it pays off.
-Patrick