Skip to main content

Posts

COUNT and GROUP Faster With N1QL

[Repost from my article at DZone:  https://dzone.com/articles/count-amp-group-faster-using-n1ql ] Humans have counted things for a  very long time . In database applications, COUNT() is frequently used in various contexts. The COUNT performance affects both application performance and user experience. Keeping this mind, Couchbase supported generalized COUNT() and has improved its performance in Couchbase 4.5 release. Two Couchbase 4.5 Features There are two features in Couchbase 4.5 helping the COUNT performance. When the query is interested only in the COUNT of a range of data that’s indexed, the indexer does the counting itself. In other words, the query pushes the counting to the index. This reduces the amount of data exchanged between indexer and query, improving the query speed. CREATE INDEX idxname ON `travel-sample` (name); SELECT COUNT (name) FROM `travel-sample` WHERE name = 'Air Alaska' ; First, ...