I'm trying to create a bulk email app that can take a database of user records and filter them by any number of attributes, much like the 'Advanced Segments' feature of Google Analytics. For example, you could specify that the email was to be sent to all 'Gold' users who registered more than 3 months ago who haven't logged in in the last 2 weeks.
My question is how to approach this filtering problem with couchdb. At the moment I have different views on 'account_type', 'registration_date' and 'last_login_date'. My program queries each view separately and returns an intersection of the resulting key arrays. This is working ok while my database is small but it's not very scalable as all the document keys have to be loaded in to memory before the intersection can happen. Does anyone have any ideas for a better way to approach this problem? Thanks, Nick
