Couchbase索引存储内容、查看方式及OOM问题技术咨询
Original Question (Translated to English)
Scenario: I'm using Couchbase database and frequently encounter OOM issues, most often caused by the Index Service running out of memory. Checking via the Couchbase Console, I see that the index foobar has X items and consumes Y memory.
Question: Can I view the data stored in the Index Service? Is it a cloned list of documents, or a list of pointer filters plus references to foo documents? What exactly is an "item"?
I checked the official documentation, which mentions "items" in the console table but doesn’t clearly define their meaning.
Node.js package in use: couchbase: "2.6.12"
1. Can You Inspect Index Service Stored Data?
No, there’s no native way to directly view the raw data stored in Couchbase’s Index Service. Indexes are optimized for query performance, not human readability, and their internal storage format is opaque to end users. You can only interact with indexes via N1QL queries or monitor metadata (like item count, memory usage) through the Couchbase Console or REST API.
2. What Does the Index Service Store?
Couchbase indexes do not store full document clones. Instead, they store a compact, query-optimized structure that typically includes:
- Values of the indexed field(s) (e.g., the
foofield values if your index targetsfoo) - A reference to the corresponding document’s ID and its location (a pointer-like entry pointing to the Data Service node holding the document)
- Optional secondary metadata for faster query processing (like sorting keys or pre-computed filter predicates)
This design prioritizes query speed while minimizing memory overhead—only the data required to satisfy queries is retained, not entire documents.
3. Definition of an "Item" in Indexes
An "item" refers to a single entry in the index that maps to either:
- One document (for simple non-array indexes): Each item corresponds to a document containing the indexed field, storing the field’s value and the document reference.
- One element of an array (for array indexes): If you index elements of an array field, each individual array element counts as a separate item.
The item count reflects the total number of distinct entries the index maintains, which directly correlates to its memory footprint.
Content sourced from Stack Exchange, question author: Scott Sword

