{"action":"created","issue":{"url":"https://api.github.com/repos/pouchdb/pouchdb/issues/4867","repository_url":"https://api.github.com/repos/pouchdb/pouchdb","labels_url":"https://api.github.com/repos/pouchdb/pouchdb/issues/4867/labels{/name}","comments_url":"https://api.github.com/repos/pouchdb/pouchdb/issues/4867/comments","events_url":"https://api.github.com/repos/pouchdb/pouchdb/issues/4867/events","html_url":"https://github.com/pouchdb/pouchdb/issues/4867","id":131153204,"number":4867,"title":"Cache ddoc views and filters for performance","user":{"login":"garethbowen","id":2064938,"avatar_url":"https://avatars.githubusercontent.com/u/2064938?v=3","gravatar_id":"","url":"https://api.github.com/users/garethbowen","html_url":"https://github.com/garethbowen","followers_url":"https://api.github.com/users/garethbowen/followers","following_url":"https://api.github.com/users/garethbowen/following{/other_user}","gists_url":"https://api.github.com/users/garethbowen/gists{/gist_id}","starred_url":"https://api.github.com/users/garethbowen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/garethbowen/subscriptions","organizations_url":"https://api.github.com/users/garethbowen/orgs","repos_url":"https://api.github.com/users/garethbowen/repos","events_url":"https://api.github.com/users/garethbowen/events{/privacy}","received_events_url":"https://api.github.com/users/garethbowen/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-02-03T21:05:52Z","updated_at":"2016-02-19T10:32:08Z","closed_at":"2016-02-19T10:32:08Z","body":"Querying persistent views [first gets and parses the ddoc](https://github.com/pouchdb/pouchdb/blob/master/src/mapreduce/index.js#L887) to get the view implementation. With a large ddoc such as  a complex couchapp this can be slow, for example with my 9MB ddoc this was taking around 1 second. Because the ddoc is parsed for each query request it quickly becomes a performance bottleneck.\r\n\r\nI wrote a dirty dirty patch to implement a `views` cache which greatly improves the performance of my app.\r\n\r\nOther areas of the code also query the ddoc for `views` and `filters` properties and so would also benefit from this change.\r\n\r\nMy proposal is to cache the `views` and `filters` on the db object and then listen for changes to the ddoc to invalidate the cache."},"comment":{"url":"https://api.github.com/repos/pouchdb/pouchdb/issues/comments/186161139","html_url":"https://github.com/pouchdb/pouchdb/issues/4867#issuecomment-186161139","issue_url":"https://api.github.com/repos/pouchdb/pouchdb/issues/4867","id":186161139,"user":{"login":"daleharvey","id":37787,"avatar_url":"https://avatars.githubusercontent.com/u/37787?v=3","gravatar_id":"","url":"https://api.github.com/users/daleharvey","html_url":"https://github.com/daleharvey","followers_url":"https://api.github.com/users/daleharvey/followers","following_url":"https://api.github.com/users/daleharvey/following{/other_user}","gists_url":"https://api.github.com/users/daleharvey/gists{/gist_id}","starred_url":"https://api.github.com/users/daleharvey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/daleharvey/subscriptions","organizations_url":"https://api.github.com/users/daleharvey/orgs","repos_url":"https://api.github.com/users/daleharvey/repos","events_url":"https://api.github.com/users/daleharvey/events{/privacy}","received_events_url":"https://api.github.com/users/daleharvey/received_events","type":"User","site_admin":false},"created_at":"2016-02-19T10:32:08Z","updated_at":"2016-02-19T10:32:08Z","body":"Fixed in https://github.com/pouchdb/pouchdb/commit/0ddeae6b6c44fa12b83c5348df6947e3ce28c28c"}}