incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David King <dk...@ketralnis.com>
Subject General-understanding questions about views
Date Sat, 28 Jun 2008 06:03:04 GMT
I'm trying to gain a fundamental understanding of views and indexed  
data. If this is documented in a FAQ, please direct me there instead :)

In trying to map my understanding from SQL, it appears that the answer  
to quickly querying data is by pre-calculating query result-sets and  
storing them in tables, called views. A view is table populated by a  
function that runs against every object that is written or modified in  
the database.

1. How would you implement a query against a value that changes after  
the view is populated, like the current time? That is, if I wanted  
things younger than a week, a permanent view like this:

function(doc) {
	if(doc.date > now() - timeinterval('1 week')) {
		emit(null,doc);
	}
}

(date-syntax liberally made up) the results of that query, if  
populated when the data is changed, would quickly be invalid, because  
now() has changed. Is this accurate? How would you performantly run a  
query like this?

2. Same question for a permanent view containing the youngest 10 items  
(this one might be easier)?

3. The wiki doesn't mention parameterised views. So if I have a  
document with an 'author' field, and I want a view such that I can see  
everything that a given author wrote, do I need a view per author?  
Given thousands of authors, what is the performance cost for running a  
document through a few thousand author-functions?

4. I know that the distribution bits are still being fleshed out, but  
is it the intention that eventually views can be stored or calculated  
on a separate server from the data (since they are implemented as  
tables)?


Mime
View raw message