-
Notifications
You must be signed in to change notification settings - Fork 298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimize indexing by letting view specify a "type" value #590
Comments
Note 1: CBLQueryBuilder can make use of this by checking whether the map predicate tests doc.type. Note 2: If we want developers not using CBLQueryBuilder to use this, we'll need an API addition — something like a |
This will automatically optimize the view indexing for a lot of common queries. For #590
There's a tech note in the wiki now, describing what this is and how to use it. |
Added a benchmark too (View_Benchmarks.m) Fixes #590 WATCH OUT: This optimization won't work correctly in SQLite-based dbs used with earlier revisions of CBL 1.1. (It does work correctly with existing 1.0.x dbs that are upgraded by this commit or later.) The reason is that the existing rows in the 'revs' table don't have the new 'doc_type' column filled in. I could write code to fill it in when adding the new column, but I don't think the work is justified since this will never affect actual users, only a few bleeding-edge adopters.
Great addition! Would it be possible to make the "type" key configurable? When my team migrated to couchbase we had a set of existing documents to migrate and couldn't use the "type" key because it was already used in them for a different purpose. |
I knew someone was going to ask that… 😬 I'll have to think about it. It's probably not too hard, but I'm not sure where to store the magic property name and how to set it. |
I have a somewhat related question in that we don't have "type", but use a document id prefix as a type descriptor. Would it be possible to make use of this ? |
Same answer, I'm afraid! If we make it configurable we can do something like letting you specify a pattern in the docID. There wasn't any issue covering making this flexible, so I've just filed one. |
It's very common for a view to index only a particular type of document, as indicated by its
type
property. So the map block will often start withif (![doc[@"type] isEqual: @"sometype"]) return;
.If we allowed a view to state that it only applies to docs with a specific
type
value, then the indexer could use that information to avoid a lot of wasted time fetching and parsing irrelevant docs:type
column torev
and index it, then restrict the indexer query to only the matching type(s).The text was updated successfully, but these errors were encountered: