{"id":2250,"date":"2016-10-11T06:20:36","date_gmt":"2016-10-11T06:20:36","guid":{"rendered":"https:\/\/www.couchbase.com\/blog\/?p=2250"},"modified":"2025-10-09T06:41:31","modified_gmt":"2025-10-09T13:41:31","slug":"1-making-most-of-your-arrays-with-covering-array-indexes-and-more","status":"publish","type":"post","link":"https:\/\/www.couchbase.com\/blog\/1-making-most-of-your-arrays-with-covering-array-indexes-and-more\/","title":{"rendered":"Making most of your Arrays.. with Covering Array Indexes  and more.."},"content":{"rendered":"<p>Hurrah!! We just released <a href=\"https:\/\/www.couchbase.com\/download\/\">Couchbase Server 4.5<\/a> which brings a bag full of wonderful features and enhancements. My earlier post <a href=\"https:\/\/www.couchbase.com\/blog\/making-the-most-of-your-arrays-with-array-indexing\/\">Making the most of your arrays&#8230; with Array Indexing<\/a> introduced the\u00a0Array Indexing functionality. This blog post includes covering array indexes, support for more\u00a0operators such as UNNEST, ALL, ANY AND EVERY etc.,<\/p>\n<h2>Covering Array Indexes<\/h2>\n<p><a href=\"https:\/\/developer.couchbase.com\/documentation\/server\/4.5\/indexes\/covering-indexes.html\"><span>\u00a0<\/span>Covering Indexes<\/a> is a performance feature in N1QL, which significantly improves the query performance by avoiding trips to the data-service to fetch any documents. There is no special syntax for creating\/using covering indexes. This is an automatic optimization triggered in N1QL, when a query can\u00a0find\u00a0all required data in the index itself. \u00a0So, covered indexes are just normal GSI<span style=\"color: #333333;line-height: 20.799999237060547px;text-align: left\">\u00a0indexes that are created with all\u00a0index-keys covering\u00a0the data\u00a0needed\u00a0for\u00a0a query. <\/span><\/p>\n<p><span style=\"color: #333333;line-height: 20.799999237060547px;text-align: left\">Typically, array indexes are created with required\u00a0elements\/attributes\u00a0with-in\u00a0the array,\u00a0as the index keys.<\/span>\u00a0And, covering indexes don&#8217;t need any special attention. However, <strong>to create\u00a0Covering Array Indexes, the\u00a0<span style=\"color: #333333;line-height: 20.799999237060547px;text-align: left\">array itself MUST also be<\/span>\u00a0added\u00a0to\u00a0the list of other index keys provided to the CREATE INDEX statement.<\/strong>\u00a0All details of the array are required\u00a0for\u00a0N1QL to properly evaluate predicates in the query. \u00a0<span style=\"line-height: 1.6em\">For example, the following command creates a covering array index on the &#8216;<em>schedule[].flight&#8217;<\/em> values in the couchbase &#8216;<em>travel-sample&#8217;<\/em> dataset:<\/span><\/p>\n<pre style=\"background-color: #eaeaea\"><code class=\"language-sql\">          CREATE INDEX isched\r\n          ON `travel-sample`(DISTINCT ARRAY i.flight FOR i IN schedule END, schedule)\r\n          WHERE (type = \"route\") AND (array_length(schedule) &lt; 10);<\/code><\/pre>\n<p>Note that the array field &#8216;<em>schedule&#8217;<\/em>\u00a0itself\u00a0is also required to be specified as an additional index key. To contrast, a non-covering array index doesn&#8217;t require\u00a0that, and is created as follows:<\/p>\n<pre style=\"background-color: #eaeaea\"><code class=\"language-sql\">          CREATE INDEX isched\r\n          ON `travel-sample`(DISTINCT ARRAY i.flight FOR i IN schedule END)\r\n          WHERE (type = \"route\") AND (array_length(schedule) &lt; 10);<\/code><\/pre>\n<p>The following SELECT statement shows how to use\u00a0the covering array index. It finds <em>&#8220;the schedules of United Airlines flight routes that have less than 10 scheduled\u00a0flights in a week&#8221;<\/em>.<\/p>\n<pre style=\"background-color: #eaeaea\"><code class=\"language-sql\">EXPLAIN SELECT schedule FROM `travel-sample` \r\nUSE INDEX(isched_covered)\r\nWHERE ANY i IN schedule SATISFIES i.flight LIKE \"UA%\" END\r\n      AND array_length(schedule) &lt; 10 \r\n      AND type = \"route\";\r\n[\r\n  {\r\n    \"plan\": {\r\n      \"#operator\": \"Sequence\",\r\n      \"~children\": [\r\n        {\r\n          \"#operator\": \"DistinctScan\",\r\n          \"scan\": {\r\n            \"#operator\": \"IndexScan\",\r\n            \"covers\": [\r\n              \"cover ((distinct (array (`i`.`flight`) for `i` in (`travel-sample`.`schedule`) end)))\",\r\n              \"cover ((`travel-sample`.`schedule`))\",\r\n              \"cover ((meta(`travel-sample`).`id`))\"\r\n            ],\r\n            \"filter_covers\": {\r\n              \"cover ((`travel-sample`.`type`))\": \"route\",\r\n              \"cover ((array_length((`travel-sample`.`schedule`)) &lt; 10))\": true\r\n            },\r\n            \"index\": \"isched_covered\",\r\n            \"index_id\": \"547b2c11add40fa6\",\r\n            \"keyspace\": \"travel-sample\",\r\n            \"namespace\": \"default\",\r\n            \"spans\": [\r\n              {\r\n                \"Range\": {\r\n                  \"High\": [\r\n                    \"\"UB\"\"\r\n                  ],\r\n                  \"Inclusion\": 0,\r\n                  \"Low\": [\r\n                    \"\"UA\"\",\r\n                    \"null\"\r\n                  ]\r\n                }\r\n              }\r\n            ],\r\n            \"using\": \"gsi\"\r\n          }\r\n        },\r\n        {\r\n          \"#operator\": \"Parallel\",\r\n          \"~child\": {\r\n            \"#operator\": \"Sequence\",\r\n            \"~children\": [\r\n              {\r\n                \"#operator\": \"Filter\",\r\n                \"condition\": \"((any `i` in cover ((`travel-sample`.`schedule`)) satisfies ((`i`.`flight`) like \"UA%\") end and cover ((array_length((`travel-sample`.`schedule`)) &lt; 10))) and (cover ((`travel-sample`.`type`)) = \"route\"))\"\r\n              },\r\n              {\r\n                \"#operator\": \"InitialProject\",\r\n                \"result_terms\": [\r\n                  {\r\n                    \"expr\": \"cover ((`travel-sample`.`schedule`))\"\r\n                  }\r\n                ]\r\n              },\r\n              {\r\n                \"#operator\": \"FinalProject\"\r\n              }\r\n            ]\r\n          }\r\n        }\r\n      ]\r\n    },\r\n    \"text\": \"SELECT schedule FROM `travel-sample` USE INDEX(isched_covered)nWHERE ANY i IN schedule SATISFIES i.flight LIKE \"UA%\" ENDn      AND array_length(schedule) &lt; 10 n      AND type = \"route\";\"\r\n  }\r\n]<\/code><\/pre>\n<p>Note that the SELECT follows the index-selection rules described in the next\u00a0sub-section.<\/p>\n<ul>\n<li>The predicates in where-clause (<em>array_length(schedule) &lt; 10)\u00a0<\/em>and (<em>type = &#8220;route&#8221;)<\/em> match those in the index definition.<\/li>\n<li>The index keys\u00a0<em>i.flight<\/em>\u00a0and\u00a0<em>schedule<\/em>\u00a0are referenced, using the exact variable \u00a0<em>&#8216;i&#8217;<\/em>\u00a0used in the index definition<\/li>\n<li>The explain query plan shows the \u00a0attributes and filters\/predicates covered by the array index &#8216;<em>isched_covered&#8217;<\/em><\/li>\n<\/ul>\n<h3><strong>Performance<\/strong><\/h3>\n<p>Covered\u00a0Array Indexes get the best performance for queries that can leverage the index. For example, <span style=\"color: #333333;line-height: 20.799999237060547px;text-align: left\">\u00a0<\/span>the above query took 8ms <span style=\"color: #333333;line-height: 20.799999237060547px;text-align: left\">in my laptop,\u00a0<\/span>when using the covered\u00a0array index &#8216;<em>isched_covered<\/em>&#8216;. However, same query using index &#8216;<em>def_type<\/em>&#8216; took 3sec. That&#8217;s a crazy <u><strong>375x<\/strong> <strong>better performance<\/strong><\/u> for this query.<\/p>\n<h2 style=\"margin-top: 0.7em;color: #333333;text-align: left\">Index selection rules<\/h2>\n<p style=\"color: #333333;line-height: 20.799999237060547px;text-align: left\">Irrespective of the operators used, the DML must follow the index-selection requirements to make use of the array index.<\/p>\n<ol style=\"color: #333333;line-height: 20.799999237060547px;text-align: left\">\n<li>The<em>\u00a0WHERE-clause<\/em>\u00a0must be used in the SELECT or other DML statements, with matching index keys specified in the CREATE INDEX definition.<\/li>\n<li>For partial indexes, the predicates used in CREATE INDEX definition must be specified in the\u00a0<em>WHERE-clause<\/em>\u00a0of the DML.<\/li>\n<li>Variable\u00a0names in the\u00a0<em>WHERE-clause<\/em>\u00a0must exactly match corresponding variable names used in the CREATE INDEX definition.<\/li>\n<\/ol>\n<p style=\"color: #333333;line-height: 20.799999237060547px;text-align: left\">When multiple matching indexes \u00a0are available, N1QL might pick any of the matching indexes for executing the query. If you prefer your query to utilize\u00a0a specific index, you can\u00a0&#8220;suggest&#8221; it by\u00a0using the USE INDEX clause to\u00a0the DML.<\/p>\n<h2><span style=\"color: #333333;line-height: 20.799999237060547px;text-align: left\">Support for\u00a0more N1QL operators<\/span><\/h2>\n<p>Couchbase 4.5 adds support for the operators <strong>UNNEST<\/strong>\u00a0and <strong>ANY AND EVERY<\/strong> to work with array indexes. \u00a0These operators can be used in the queries with both covered, and non-covered array indexes.\u00a0Note that:<\/p>\n<ul>\n<li><strong>ANY<\/strong> operator is already supported i<span style=\"color: #333333;line-height: 20.799999237060547px;text-align: left\">n the Developer Preview release. See example above.<\/span><\/li>\n<li><span style=\"color: #333333;line-height: 20.799999237060547px;text-align: left\"><strong>EVERY<\/strong> operator is not supported in\u00a0Couchbase 4.5. \u00a0However, note that the ANY AND EVERY operator is supported.\u00a0 To clarify, EVERY operator evaluates to true for arrays with zero elements,\u00a0whereas\u00a0ANY AND EVERY evaluates to true when the\u00a0array has atleast one\u00a0matching element.<\/span><\/li>\n<\/ul>\n<h2>Using UNNEST with Array Indexes<\/h2>\n<p><span style=\"color: #333333;line-height: 20.799999237060547px;text-align: left\">Array-indexing supports the\u00a0<\/span><a href=\"https:\/\/developer.couchbase.com\/documentation\/server\/current\/n1ql\/n1ql-language-reference\/from.html\">UNNEST<\/a> operator which can be used to flatten the\u00a0array attribute\u00a0on which the index is created, and use it\u00a0as part of\u00a0the query. The UNNEST statement must use the exact same variable name (i.e &#8216;<em>i\u00a0<\/em>&#8216; in this example)\u00a0as used in the CREATE INDEX statement.\u00a0For example, the following query finds <em>&#8220;<\/em><em style=\"color: #333333;line-height: 20.799999237060547px;text-align: left\">the details of United Airlines flight routes that have less than 10 scheduled\u00a0flights in a week<\/em><em>&#8220;<\/em>.<\/p>\n<pre style=\"background-color: #eaeaea\"><code class=\"language-sql\">EXPLAIN SELECT i FROM `travel-sample` t \r\nUSE INDEX (isched_covered) \r\nUNNEST t.schedule AS i \r\nWHERE (i.flight LIKE \"UA%\") AND (array_length(t.schedule) &lt; 10) AND (t.type = \"route\");\r\n[\r\n  {\r\n    \"plan\": {\r\n      \"#operator\": \"Sequence\",\r\n      \"~children\": [\r\n        {\r\n          \"#operator\": \"DistinctScan\",\r\n          \"scan\": {\r\n            \"#operator\": \"IndexScan\",\r\n            \"covers\": [\r\n              \"cover ((distinct (array (`i`.`flight`) for `i` in (`t`.`schedule`) end)))\",\r\n              \"cover ((`t`.`schedule`))\",\r\n              \"cover ((meta(`t`).`id`))\"\r\n            ],\r\n            \"filter_covers\": {\r\n              \"cover ((`t`.`type`))\": \"route\",\r\n              \"cover ((array_length((`t`.`schedule`)) &lt; 10))\": true\r\n            },\r\n            \"index\": \"isched_covered\",\r\n            \"index_id\": \"547b2c11add40fa6\",\r\n            \"keyspace\": \"travel-sample\",\r\n            \"namespace\": \"default\",\r\n            \"spans\": [\r\n              {\r\n                \"Range\": {\r\n                  \"High\": [\r\n                    \"\"UB\"\"\r\n                  ],\r\n                  \"Inclusion\": 1,\r\n                  \"Low\": [\r\n                    \"\"UA\"\"\r\n                  ]\r\n                }\r\n              }\r\n            ],\r\n            \"using\": \"gsi\"\r\n          }\r\n        },\r\n        {\r\n          \"#operator\": \"Parallel\",\r\n          \"~child\": {\r\n            \"#operator\": \"Sequence\",\r\n            \"~children\": [\r\n              {\r\n                \"#operator\": \"Unnest\",\r\n                \"as\": \"i\",\r\n                \"expr\": \"cover ((`t`.`schedule`))\"\r\n              },\r\n              {\r\n                \"#operator\": \"Filter\",\r\n                \"condition\": \"((((`i`.`flight`) like \"UA%\") and cover ((array_length((`t`.`schedule`)) &lt; 10))) and (cover ((`t`.`type`)) = \"route\"))\"\r\n              },\r\n              {\r\n                \"#operator\": \"InitialProject\",\r\n                \"result_terms\": [\r\n                  {\r\n                    \"expr\": \"`i`\"\r\n                  }\r\n                ]\r\n              },\r\n              {\r\n                \"#operator\": \"FinalProject\"\r\n              }\r\n            ]\r\n          }\r\n        }\r\n      ]\r\n    },\r\n    \"text\": \"SELECT i FROM `travel-sample` t nUSE INDEX (isched_covered) nUNNEST t.schedule AS i nWHERE (i.flight LIKE \"UA%\") AND (array_length(t.schedule) &lt; 10) AND (t.type = \"route\");\"\r\n  }\r\n]<\/code><\/pre>\n<p><strong style=\"color: #333333;line-height: 20.799999237060547px;text-align: left\">Performance<\/strong><\/p>\n<p><span style=\"color: #333333;line-height: 20.799999237060547px;text-align: left\">Covered\u00a0<\/span><span style=\"color: #333333;line-height: 20.799999237060547px;text-align: left\">Array Indexes get the best performance for queries that can leverage the index. For example,\u00a0<\/span><span style=\"color: #333333;line-height: 20.799999237060547px;text-align: left\">\u00a0<\/span><span style=\"color: #333333;line-height: 20.799999237060547px;text-align: left\">the above query took 8<\/span><span style=\"color: #333333;line-height: 20.799999237060547px;text-align: left\">ms\u00a0<\/span><span style=\"color: #333333;line-height: 20.799999237060547px;text-align: left\">in my laptop,\u00a0<\/span><span style=\"color: #333333;line-height: 20.799999237060547px;text-align: left\">when using the covered<\/span><span style=\"color: #333333;line-height: 20.799999237060547px;text-align: left\">\u00a0array index &#8216;<\/span><em style=\"color: #333333;line-height: 20.799999237060547px;text-align: left\">isched_covered<\/em><span style=\"color: #333333;line-height: 20.799999237060547px;text-align: left\">&#8216;<\/span><span style=\"color: #333333;line-height: 20.799999237060547px;text-align: left\">. However, same query using index &#8216;<\/span><em style=\"color: #333333;line-height: 20.799999237060547px;text-align: left\">def_type<\/em><span style=\"color: #333333;line-height: 20.799999237060547px;text-align: left\">&#8216; took 28<\/span><span style=\"color: #333333;line-height: 20.799999237060547px;text-align: left\">sec. That&#8217;s an insane\u00a0<u><strong>3500x better performance<\/strong><\/u> for this query.<\/span><\/p>\n<h2>Using ANY AND EVERY\u00a0\u00a0with Array Indexes<\/h2>\n<p><span style=\"color: #333333;line-height: 20.799999237060547px;text-align: left\">Array-indexing supports\u00a0<a href=\"https:\/\/developer.couchbase.com\/documentation\/server\/current\/n1ql\/n1ql-language-reference\/collectionops.html\">ANY AND EVERY<\/a> operator. This\u00a0can be used to find a boolean match across a non-null set of array elements\u00a0on which the array index is created. For example, the following query finds\u00a0<em>\u00a0&#8220;the <\/em><\/span><em style=\"color: #333333;line-height: 20.799999237060547px;text-align: left\">schedule<\/em><span style=\"color: #333333;line-height: 20.799999237060547px;text-align: left\"><em>\u00a0of routes that have atleast 1, but less than\u00a010, \u00a0all United Airlines\u00a0flights in a week&#8221;<\/em>.<\/span><\/p>\n<pre style=\"background-color: #eaeaea\"><code class=\"language-sql\">SELECT schedule FROM `travel-sample`\r\nUSE INDEX (isched_covered)\r\nWHERE ANY AND EVERY i IN schedule SATISFIES i.flight LIKE 'UA%' END\r\nAND array_length(schedule) &lt; 10\r\nAND type = \"route\";<\/code><\/pre>\n<h2 dir=\"ltr\" style=\"line-height: 1.44;margin-top: 12pt;margin-bottom: 5pt\"><span style=\"font-size: 22.666666666666664px;font-family: Arial;color: #333333;vertical-align: baseline\">Using ALL with Array Index<\/span><\/h2>\n<p dir=\"ltr\" style=\"line-height: 1.8719999313354492;margin-top: 0pt;margin-bottom: 3pt\"><span style=\"color: #333333;font-family: Arial;line-height: 24px;text-align: left\">In Couchbase 4.5<\/span>, array indexes can be created using\u00a0<span style=\"color: #333333;font-family: Arial;line-height: 24px;text-align: left\">CREATE INDEX with the keyword DISTINCT ARRAY only.<\/span>\u00a0<span style=\"font-size: 13.333333333333332px;font-family: Arial;color: #333333;font-weight: 400;vertical-align: baseline\">Couchbase 4.5 release adds support for the ALL keyword to create the array index with all values of the array elements. For example, <\/span><\/p>\n<pre style=\"background-color: #eaeaea\"><code class=\"language-sql\">         CREATE INDEX isched_all\r\n         ON `travel-sample`(ALL ARRAY i.flight FOR i IN schedule END)\r\n         WHERE (type = \"route\") AND (array_length(schedule) &lt; 10);<\/code><\/pre>\n<p dir=\"ltr\" style=\"margin-top: 0pt;margin-bottom: 0pt\"><span style=\"background-color: transparent;vertical-align: baseline\">You can learn more about array indexing and see more examples, such as composite and nested array indexes, in the Couchbase 4.5 <a href=\"https:\/\/developer.couchbase.com\/documentation\/server\/4.5\/n1ql\/n1ql-language-reference\/indexing-arrays.html\">documentation<\/a>, and checkout the<\/span> <a style=\"text-decoration: none\" href=\"https:\/\/www.youtube.com\/v\/FuCaLGT_q1g?start=36&amp;end=216\"><span style=\"color: #0000ff;background-color: transparent;text-decoration: underline;vertical-align: baseline\">demo.<\/span><\/a><\/p>\n<p dir=\"ltr\" style=\"margin-top: 0pt;margin-bottom: 0pt\">Give it a try, and let me know any questions\/comments, or just how awesome it is ;-)<\/p>\n<p>Cheers!!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hurrah!! We just released Couchbase Server 4.5 which brings a bag full of wonderful features and enhancements. My earlier post Making the most of your arrays&#8230; with Array Indexing introduced the\u00a0Array Indexing functionality. This blog post includes covering array indexes, [&hellip;]<\/p>\n","protected":false},"author":70,"featured_media":13873,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[1812],"tags":[2012],"ppma_author":[8935],"class_list":["post-2250","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-n1ql-query","tag-array-indexing"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.2 (Yoast SEO v26.2) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Composite and nested array indexes in the Couchbase 4.5<\/title>\n<meta name=\"description\" content=\"Learn how to create Covering Array Indexes, the array itself MUST also be added to the list of other index keys provided to the CREATE INDEX statement.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.couchbase.com\/blog\/1-making-most-of-your-arrays-with-covering-array-indexes-and-more\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Making most of your Arrays.. with Covering Array Indexes and more..\" \/>\n<meta property=\"og:description\" content=\"Learn how to create Covering Array Indexes, the array itself MUST also be added to the list of other index keys provided to the CREATE INDEX statement.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.couchbase.com\/blog\/1-making-most-of-your-arrays-with-covering-array-indexes-and-more\/\" \/>\n<meta property=\"og:site_name\" content=\"The Couchbase Blog\" \/>\n<meta property=\"article:published_time\" content=\"2016-10-11T06:20:36+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-10-09T13:41:31+00:00\" \/>\n<meta name=\"author\" content=\"Prasad Varakur, Principal Product Manager, Couchbase\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Prasad Varakur, Principal Product Manager, Couchbase\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/1-making-most-of-your-arrays-with-covering-array-indexes-and-more\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/1-making-most-of-your-arrays-with-covering-array-indexes-and-more\/\"},\"author\":{\"name\":\"Prasad Varakur, Principal Product Manager, Couchbase\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/c649b2296584f6b734c5a21681137e46\"},\"headline\":\"Making most of your Arrays.. with Covering Array Indexes and more..\",\"datePublished\":\"2016-10-11T06:20:36+00:00\",\"dateModified\":\"2025-10-09T13:41:31+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/1-making-most-of-your-arrays-with-covering-array-indexes-and-more\/\"},\"wordCount\":907,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/1-making-most-of-your-arrays-with-covering-array-indexes-and-more\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png\",\"keywords\":[\"Array Indexing\"],\"articleSection\":[\"SQL++ \/ N1QL Query\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/1-making-most-of-your-arrays-with-covering-array-indexes-and-more\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/1-making-most-of-your-arrays-with-covering-array-indexes-and-more\/\",\"url\":\"https:\/\/www.couchbase.com\/blog\/1-making-most-of-your-arrays-with-covering-array-indexes-and-more\/\",\"name\":\"Composite and nested array indexes in the Couchbase 4.5\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/1-making-most-of-your-arrays-with-covering-array-indexes-and-more\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/1-making-most-of-your-arrays-with-covering-array-indexes-and-more\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png\",\"datePublished\":\"2016-10-11T06:20:36+00:00\",\"dateModified\":\"2025-10-09T13:41:31+00:00\",\"description\":\"Learn how to create Covering Array Indexes, the array itself MUST also be added to the list of other index keys provided to the CREATE INDEX statement.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/1-making-most-of-your-arrays-with-covering-array-indexes-and-more\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/1-making-most-of-your-arrays-with-covering-array-indexes-and-more\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/1-making-most-of-your-arrays-with-covering-array-indexes-and-more\/#primaryimage\",\"url\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png\",\"contentUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png\",\"width\":1800,\"height\":630},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/1-making-most-of-your-arrays-with-covering-array-indexes-and-more\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.couchbase.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Making most of your Arrays.. with Covering Array Indexes and more..\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#website\",\"url\":\"https:\/\/www.couchbase.com\/blog\/\",\"name\":\"The Couchbase Blog\",\"description\":\"Couchbase, the NoSQL Database\",\"publisher\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.couchbase.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\",\"name\":\"The Couchbase Blog\",\"url\":\"https:\/\/www.couchbase.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png\",\"contentUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png\",\"width\":218,\"height\":34,\"caption\":\"The Couchbase Blog\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/c649b2296584f6b734c5a21681137e46\",\"name\":\"Prasad Varakur, Principal Product Manager, Couchbase\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/5d664f4b9aadb80e438fd06cce0d151e\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/3dd2299380c7af4e8a9732a0465d1c082c95eaff26cdf4abf54816d9b693043a?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/3dd2299380c7af4e8a9732a0465d1c082c95eaff26cdf4abf54816d9b693043a?s=96&d=mm&r=g\",\"caption\":\"Prasad Varakur, Principal Product Manager, Couchbase\"},\"description\":\"Prasad Varakur is a Principal Product Manager, Couchbase. Prasad is Product and Engineering leader in Databases(SQL, noSQL, Bigdata) &amp; Distributed systems.\",\"url\":\"https:\/\/www.couchbase.com\/blog\/author\/prasad-varakur\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Composite and nested array indexes in the Couchbase 4.5","description":"Learn how to create Covering Array Indexes, the array itself MUST also be added to the list of other index keys provided to the CREATE INDEX statement.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.couchbase.com\/blog\/1-making-most-of-your-arrays-with-covering-array-indexes-and-more\/","og_locale":"en_US","og_type":"article","og_title":"Making most of your Arrays.. with Covering Array Indexes and more..","og_description":"Learn how to create Covering Array Indexes, the array itself MUST also be added to the list of other index keys provided to the CREATE INDEX statement.","og_url":"https:\/\/www.couchbase.com\/blog\/1-making-most-of-your-arrays-with-covering-array-indexes-and-more\/","og_site_name":"The Couchbase Blog","article_published_time":"2016-10-11T06:20:36+00:00","article_modified_time":"2025-10-09T13:41:31+00:00","author":"Prasad Varakur, Principal Product Manager, Couchbase","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Prasad Varakur, Principal Product Manager, Couchbase","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.couchbase.com\/blog\/1-making-most-of-your-arrays-with-covering-array-indexes-and-more\/#article","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/1-making-most-of-your-arrays-with-covering-array-indexes-and-more\/"},"author":{"name":"Prasad Varakur, Principal Product Manager, Couchbase","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/c649b2296584f6b734c5a21681137e46"},"headline":"Making most of your Arrays.. with Covering Array Indexes and more..","datePublished":"2016-10-11T06:20:36+00:00","dateModified":"2025-10-09T13:41:31+00:00","mainEntityOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/1-making-most-of-your-arrays-with-covering-array-indexes-and-more\/"},"wordCount":907,"commentCount":0,"publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/1-making-most-of-your-arrays-with-covering-array-indexes-and-more\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png","keywords":["Array Indexing"],"articleSection":["SQL++ \/ N1QL Query"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.couchbase.com\/blog\/1-making-most-of-your-arrays-with-covering-array-indexes-and-more\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.couchbase.com\/blog\/1-making-most-of-your-arrays-with-covering-array-indexes-and-more\/","url":"https:\/\/www.couchbase.com\/blog\/1-making-most-of-your-arrays-with-covering-array-indexes-and-more\/","name":"Composite and nested array indexes in the Couchbase 4.5","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/1-making-most-of-your-arrays-with-covering-array-indexes-and-more\/#primaryimage"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/1-making-most-of-your-arrays-with-covering-array-indexes-and-more\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png","datePublished":"2016-10-11T06:20:36+00:00","dateModified":"2025-10-09T13:41:31+00:00","description":"Learn how to create Covering Array Indexes, the array itself MUST also be added to the list of other index keys provided to the CREATE INDEX statement.","breadcrumb":{"@id":"https:\/\/www.couchbase.com\/blog\/1-making-most-of-your-arrays-with-covering-array-indexes-and-more\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.couchbase.com\/blog\/1-making-most-of-your-arrays-with-covering-array-indexes-and-more\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/1-making-most-of-your-arrays-with-covering-array-indexes-and-more\/#primaryimage","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png","width":1800,"height":630},{"@type":"BreadcrumbList","@id":"https:\/\/www.couchbase.com\/blog\/1-making-most-of-your-arrays-with-covering-array-indexes-and-more\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.couchbase.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Making most of your Arrays.. with Covering Array Indexes and more.."}]},{"@type":"WebSite","@id":"https:\/\/www.couchbase.com\/blog\/#website","url":"https:\/\/www.couchbase.com\/blog\/","name":"The Couchbase Blog","description":"Couchbase, the NoSQL Database","publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.couchbase.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.couchbase.com\/blog\/#organization","name":"The Couchbase Blog","url":"https:\/\/www.couchbase.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png","width":218,"height":34,"caption":"The Couchbase Blog"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/c649b2296584f6b734c5a21681137e46","name":"Prasad Varakur, Principal Product Manager, Couchbase","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/5d664f4b9aadb80e438fd06cce0d151e","url":"https:\/\/secure.gravatar.com\/avatar\/3dd2299380c7af4e8a9732a0465d1c082c95eaff26cdf4abf54816d9b693043a?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/3dd2299380c7af4e8a9732a0465d1c082c95eaff26cdf4abf54816d9b693043a?s=96&d=mm&r=g","caption":"Prasad Varakur, Principal Product Manager, Couchbase"},"description":"Prasad Varakur is a Principal Product Manager, Couchbase. Prasad is Product and Engineering leader in Databases(SQL, noSQL, Bigdata) &amp; Distributed systems.","url":"https:\/\/www.couchbase.com\/blog\/author\/prasad-varakur\/"}]}},"authors":[{"term_id":8935,"user_id":70,"is_guest":0,"slug":"prasad-varakur","display_name":"Prasad Varakur, Principal Product Manager, Couchbase","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/3dd2299380c7af4e8a9732a0465d1c082c95eaff26cdf4abf54816d9b693043a?s=96&d=mm&r=g","author_category":"","last_name":"Varakur","first_name":"Prasad","job_title":"","user_url":"","description":"Prasad Varakur is a Principal Product Manager, Couchbase. Prasad is Product and Engineering leader in Databases(SQL, noSQL, Bigdata) &amp; Distributed systems."}],"_links":{"self":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts\/2250","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/users\/70"}],"replies":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/comments?post=2250"}],"version-history":[{"count":0,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts\/2250\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/media\/13873"}],"wp:attachment":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/media?parent=2250"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/categories?post=2250"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/tags?post=2250"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=2250"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}