Sat. Sep 24th, 2022

This post will provide an in depth and clear comparison between the Cloudant design documents. Provides an easy way to finalize which design document is applicable in your use case.

Types of Design Documents

  • Cloudant Query
  • Query Index
  • Views
  • Search Index

Comparison of Design Documents

PaginationSortFilter
BookmarkSkipLimitMax Limit
Cloudant QueryYesYesNo limitAt least one of the sort fields should be included in the selector. An index should exist, with all the sort fields in the same orderAccepts any fields in the selector. Only sort fields have restriction
Query IndexYesYesjson: No limit
text: 200
At least one of the sort fields should be included in the selector. An index should exist, with all the sort fields in the same order Accepts any fields in the selector. Only sort fields have restriction
ViewsNoYesYesNo limit
Sort is applied only to the key defined in the view function. Sort is specified using ‘descending = true’
Filters only on indexed fields
Search IndexYesNoYes200Sorts an array of indexed fieldsFilters only on indexed fields

Performance tests

TimeTakeninsecondsAverage
Search Index0.09210.17370.08240.08630.08620.1041
View (single key)0.02450.02960.02320.02630.02290.0253
View (multiple key)0.02940.02480.02510.030.03370.0286
Cloudant Query0.12450.2010.20250.12240.23620.1773
Query Index (json)0.060.05530.05720.06090.05520.0577
Query Index (text)0.06430.06770.07270.06950.08560.0719

Test setup

  • Database contains 100k records
  • Each query resulted in 100 records
  • Search Index is queried using a set of 100 search strings each concatenated with an OR clause
  • Views performance is better when queried through startkey and endkey instead of a set of keys. The below values are calculated using a start and end key for 100 values
  • Cloudant Query is performed with an $and clause where <search-string> $gt 1 and <search-string> $lt 100

Take aways

  • The Search Index yields better performance and also has more flexible querying options. Any indexed field can be searched by itself or in conjunction with other indexed fields and hence search indexes are more flexible with future requirements.
  • Views consume very less time when compared to other indexes. But they do not provide much flexibility in querying and sorting when compared with the Search Index
  • Cloudant Query is slower when used without a query index. Further in Query index, json type index restricts on some operators usage whereas text type index has flexibility in this regard.
  • Also, when compared to Search Index, Query Index is taking more time while using regex match in the query
  • Both Search Index and text type Query Index have maximum limit of 200 records. Behind the screen, text type index uses Lucene indexer similar to Search Index

Conclusion

Use Views or Search Indexes for your application use cases.

Leave a Reply

Your email address will not be published. Required fields are marked *