The Couchbase Bucket List: 7 Queries to Run Before You Die

April 5, 2026

A bucket list for people who store data in buckets.

Every developer has a bucket list. Ours just happens to involve actual buckets — Couchbase buckets. Here are the 7 N1QL queries every developer should run at least once in their life.

1. The Self-Join. SELECT * FROM mybucket a JOIN mybucket b ON a.id = b.parent_id. You don't need it. Nobody needs it. But running it makes you feel powerful, like a DBA who's seen things.

2. The UNNEST. Flattening an array inside a document feels like performing surgery on JSON. You reach in, pull out the nested array, and spread it across rows like a data surgeon. It's beautiful and slightly terrifying.

3. The COUNT(*) on a million documents. Just to watch the primary index sweat. Time it. Tell your colleagues. They won't care, but you'll know.

4. The EXPLAIN. EXPLAIN SELECT * FROM mybucket WHERE type = 'beer'. Reading query plans is the crossword puzzle of database engineering. You pretend to understand it, nod wisely, and then add an index.

5. The CREATE INDEX with DEFER_BUILD. Because sometimes you want to create an index but not actually build it. It's the database equivalent of buying gym equipment and leaving it in the box.

6. The DELETE WHERE 1=1. On a test bucket, obviously. The rush of deleting everything in a single query is something PostgreSQL users will never understand. No foreign key constraints stopping you. No cascade warnings. Just gone. Freedom.

7. The META().id query. SELECT META().id, * FROM mybucket LIMIT 1. Your first query. The one that started it all. The moment you realized that in Couchbase, every document has a secret identity hidden in its metadata. It's like finding out your quiet coworker is actually Batman.

Now go forth and query. Your bucket awaits.