optimization - Couchdb views and many (thousands) document types -


i'm studing couchdb , i'm picturing worst case scenario:

for each document type need 3 view , application can generate 10 thousands of document types.

with "document type" mean structure of document.

after insertion of new document, couchdb make 3*10k calls view functions searching right document type.

is true? there smart solution make database each doc type?

document example (assume none documents have same structure, in example data under different keys):

[      {        "_id":"1251888780.0",        "_rev":"1-582726400f3c9437259adef7888cbac0"        "type":'sensorx',        "value":{"valuea":"123"}      },      {        "_id":"1251888780.0",        "_rev":"1-37259adef7888cbac06400f3c9458272"        "type":'sensory',        "value":{"valueb":"456"}      },      {        "_id":"1251888780.0",        "_rev":"1-6400f3c945827237259adef7888cbac0"        "type":'sensorz',        "value":{"valuec":"789"}      },    ] 

views example (in example 1 per doc type)

  "views":   {     "sensorx": {       "map": "function(doc) { if (doc.type == 'sensorx')  emit(null, doc.valuea) }"     },     "sensory": {       "map": "function(doc) { if (doc.type == 'sensory')  emit(null, doc.valueb) }"     },     "sensorz": {       "map": "function(doc) { if (doc.type == 'sensorz')  emit(null, doc.valuec) }"     },   } 

the results of map() function in couchdb cached first time request view each new document. let me explain quick illustration.

  • you insert 100 documents couchdb

  • you request view. 100 documents have map() function run against them , results cached.

  • you request view again. data read indexed view data, no documents have re-mapped.

  • you insert 50 more documents

  • you request view. 50 new documents mapped , merged index old 100 documents.

  • you request view again. data read indexed view data, no documents have re-mapped.

i hope makes sense. if you're concerned big load being generated when user requests view , lots of new documents have been added @ having import process call view (to re-map new documents) , have user request view include stale=ok.

the couchdb book resource information on couchdb.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -