{"id":3968,"date":"2017-08-25T01:09:33","date_gmt":"2017-08-25T08:09:33","guid":{"rendered":"https:\/\/www.couchbase.com\/blog\/?p=3968"},"modified":"2025-06-13T17:23:17","modified_gmt":"2025-06-14T00:23:17","slug":"paging-data-queries-with-n1ql","status":"publish","type":"post","link":"https:\/\/www.couchbase.com\/blog\/paging-data-queries-with-n1ql\/","title":{"rendered":"Paging Data Queries with N1QL"},"content":{"rendered":"<p><em>M. David Allen is a full-stack software engineer and entrepreneur who for more than a decade has been working with just about every different programming language and different type of database system he could get his hands on. \u00a0David has previously worked across many industries including finance, healthcare, and government, typically focusing on large-scale data integration challenges, transitioning applied research, and new technology innovation. \u00a0He holds a masters degree from Virginia Commonwealth University but since leaving formal education remains a permanent student of technology.<\/em><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-5662\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2017\/09\/Simple-Small-Headshot-450x300-compressed-300x200.png\" alt=\"\" width=\"410\" height=\"273\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2017\/09\/Simple-Small-Headshot-450x300-compressed-300x200.png 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2017\/09\/Simple-Small-Headshot-450x300-compressed-400x267.png 400w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2017\/09\/Simple-Small-Headshot-450x300-compressed.png 450w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2017\/09\/Simple-Small-Headshot-450x300-compressed-20x13.png 20w\" sizes=\"auto, (max-width: 410px) 100vw, 410px\" \/><\/p>\n<h2>Setup<\/h2>\n<p>For this tutorial, we\u2019ll be using the <u><a href=\"https:\/\/developer.couchbase.com\/documentation\/server\/4.1\/developer-guide\/sample-bucket-beer.html\" target=\"_blank\" rel=\"noopener noreferrer\">beer-sample dataset<\/a><\/u>\u00a0that comes with Couchbase so it will be easy to follow along. \u00a0 If you don\u2019t yet have Couchbase installed, you can get going very quickly by having docker and <u><a href=\"https:\/\/hub.docker.com\/_\/couchbase\/\" target=\"_blank\" rel=\"noopener noreferrer\">following the easy instructions on the couchbase docker image page<\/a><\/u>\u00a0to set up a quick instance of Couchbase for testing. \u00a0 \u00a0Simply running the command docker run -d &#8211;name db -p 8091-8094:8091-8094 -p 11210:11210 Couchbase with Couchbase installed gets us started. \u00a0 After following a few setup prompts described on that page, we\u2019re ready to roll with some data.<\/p>\n<h2>Use Cases &#8211; What is Paging, and why do it?<\/h2>\n<p>Let\u2019s consider a very common needs; in our hypothetical front-end beer application, we want to show our users a table of beers and let them rate each one. \u00a0The problem is that the database has over 5,000 beers in it. \u00a0It\u2019d be a waste to send the whole dataset to the browser every time, and would really slow down the loading of your web application\u2019s page.<\/p>\n<p>Much better would be to show the user only the first 10 beers. \u00a0Then, by either clicking a \u201cNext\u201d button to go to the next page, or even better by using an infinite scroll plugin (such as <u><a href=\"https:\/\/sroze.github.io\/ngInfiniteScroll\/\" target=\"_blank\" rel=\"noopener noreferrer\">ngInfiniteScroll<\/a><\/u>\u00a0for angular or<u><a href=\"https:\/\/github.com\/seatgeek\/react-infinite\" target=\"_blank\" rel=\"noopener noreferrer\">\u00a0react-infinite<\/a><\/u>\u00a0for react) the user can be shown progressively more of the records from the database.<\/p>\n<h2>Show me the Code!<\/h2>\n<pre class=\"lang:default decode:true\">SELECT name, category, abv from `beer-sample`\r\n\r\nWHERE brewery_id is not missing\r\n\r\nORDER BY name\r\n\r\nOFFSET 0\r\n\r\nLIMIT 10;<\/pre>\n<p>This returns the data you\u2019d expect:<\/p>\n<pre class=\"lang:default decode:true\">[\r\n\r\n\u00a0 {\r\n\r\n\u00a0 \u00a0 \"abv\": 0,\r\n\r\n\u00a0 \u00a0 \"category\": \"North American Lager\",\r\n\r\n\u00a0 \u00a0 \"name\": \"#17 Cream Ale\"\r\n\r\n\u00a0 },\r\n\r\n\u00a0 {\r\n\r\n\u00a0 \u00a0 \"abv\": 0,\r\n\r\n\u00a0 \u00a0 \"name\": \"#40 Golden Lager\"\r\n\r\n\u00a0 },\r\n\r\n\u00a0 {\r\n\r\n\u00a0 \u00a0 \"abv\": 0,\r\n\r\n\u00a0 \u00a0 \"category\": \"Other Style\",\r\n\r\n\u00a0 \u00a0 \"name\": \"#42 Cream Ale\"\r\n\r\n\u00a0 },\r\n\r\n\u00a0 \/* (...) *\/\r\n\r\n<\/pre>\n<p>To get the second page of results, you only need to add the LIMIT to the OFFSET. \u00a0 \u00a0For example, OFFSET 10 LIMIT 10 would be the second page. \u00a0 To generalize this, how many records should you skip over with OFFSET in order to get to the nth page? \u00a0 \u00a0It will always be n * page size.<\/p>\n<p>Using this simple math, we can generalize this to any scenario. \u00a0What if we wanted to show 20 results at a time, and the user wanted to jump straight to the 11th page? \u00a0 No problem, it\u2019s just LIMIT 20 OFFSET 20 * 11. \u00a0 Application endpoints then, whether they\u2019re searching the database, or just listing beers by name, can use the exact same query logic each time. \u00a0No matter how complex the query is, just adjust LIMIT and OFFSET and we\u2019re all on the same page.<\/p>\n<h2>How does this work?<\/h2>\n<p>The magic here is the combination of three N1QL clauses: \u00a0<strong>LIMIT<\/strong>, <strong>OFFSET<\/strong>, and <strong>ORDER BY<\/strong>. \u00a0 Let\u2019s take a quick look at each, because they\u2019re all needed to get the job done.<\/p>\n<ul>\n<li><strong><a href=\"https:\/\/developer.couchbase.com\/documentation\/server\/current\/n1ql\/n1ql-language-reference\/limit.html\" target=\"_blank\" rel=\"noopener noreferrer\">LIMIT<\/a><\/strong>\u00a0does just what it says. It limits how many records Couchbase will return, and effectively enforces our page size (we only want 10 beers at a time, never 5,000)<\/li>\n<li><strong><a href=\"https:\/\/developer.couchbase.com\/documentation\/server\/current\/n1ql\/n1ql-language-reference\/offset.html\" target=\"_blank\" rel=\"noopener noreferrer\">OFFSET<\/a><\/strong>\u00a0tells Couchbase how many records to jump over before it begins returning documents. If you\u2019re familiar with SQL, it behaves just like SKIP in SQL. The OFFSET clause is how we move forward through the entire data set one chunk at a time.<\/li>\n<li><strong><a href=\"https:\/\/developer.couchbase.com\/documentation\/server\/current\/n1ql\/n1ql-language-reference\/orderby.html\" target=\"_blank\" rel=\"noopener noreferrer\">ORDER BY<\/a><\/strong>\u00a0guarantees a certain order returned by the database. This is important because Couchbase doesn\u2019t guarantee any particular order of the results unless you ask for it. \u00a0In our previous query, the #17 Cream Ale appeared as the first result when ordering by name. If we didn\u2019t use ORDER BY, we wouldn\u2019t be able to predict where in the set the #17 Cream Ale would appear, and it might be possible it could appear on more than one page depending on how Couchbase executed the query!<\/li>\n<\/ul>\n<p>Put simply, imagine Couchbase building a list of all of the beers ordered by name (ORDER BY). \u00a0Pagination is just taking batches of 10 of them (LIMIT 10). \u00a0 Each page then starts by skipping through the entire ordered list to the starting point of the next page (OFFSET).<\/p>\n<h2>EXPLAIN yourself, Couchbase.<\/h2>\n<p>One final example; as with any N1QL query, you can gain a lot of insight into how it works by just putting \u201cEXPLAIN\u201d in front of it. \u00a0This tells Couchbase to tell you what it\u2019s planning to do.<\/p>\n<pre class=\"lang:default decode:true\">EXPLAIN SELECT name, category, abv from `beer-sample`\r\n\r\nWHERE brewery_id is not missing\r\n\r\nORDER BY name\r\n\r\nOFFSET 0\r\n\r\nLIMIT 10;\r\n\r\n<\/pre>\n<p>(Try this query for yourself!) \u00a0The output is rather long, so we won\u2019t paste it here, but let\u2019s summarize what Couchbase is doing with this query.<\/p>\n<ol>\n<li>It first does a primary scan of the beer-sample bucket, and fetches documents.<\/li>\n<li>In parallel, it filters for:\n<ol>\n<li>Records that have a brewery_id (this tell us the record is a beer, not a brewery document)<\/li>\n<li>It projects out the name, category, and abv properties (what we asked for)<\/li>\n<\/ol>\n<\/li>\n<li>It then orders the results by name<\/li>\n<li>The offset is applied next, effectively skipping the first X records and not returning them at all.<\/li>\n<li>Finally, it applies the LIMIT by reading the next n records, and ignoring all those after it.<\/li>\n<\/ol>\n<h2>When are we done?<\/h2>\n<p>If we\u2019re moving through our data one page at a time, we also need to know when to stop. \u00a0There are two ways of approaching this; on one hand, if we keep advancing through the pages indefinitely, we\u2019ll eventually run out of data. \u00a0 On the other hand, you could just pre-compute how many pages are present, and then iterate through them until you hit that number.<\/p>\n<p>What happens if we ask for the 7th page of 1,000 results, knowing full well that there isn\u2019t any such document set?<\/p>\n<pre class=\"lang:default decode:true\">SELECT name, category, abv from `beer-sample`\r\n\r\nWHERE brewery_id is not missing\r\n\r\nORDER BY name\r\n\r\nOFFSET 7 * 1000\r\n\r\nLIMIT 1000;\r\n\r\n<\/pre>\n<p>Well, never fear &#8212; if you go past the end, you\u2019ll just get an empty array.<\/p>\n<pre class=\"lang:default decode:true\">{\r\n\r\n\u00a0 \"results\": [],\r\n\r\n\u00a0 \"metrics\": {\r\n\r\n\u00a0 \u00a0 \"elapsedTime\": \"465.446327ms\",\r\n\r\n\u00a0 \u00a0 \"executionTime\": \"465.384101ms\",\r\n\r\n\u00a0 \u00a0 \"resultCount\": 0,\r\n\r\n\u00a0 \u00a0 \"resultSize\": 0,\r\n\r\n\u00a0 \u00a0 \"sortCount\": 5891\r\n\r\n\u00a0 }\r\n\r\n}\r\n\r\n<\/pre>\n<p>For the record, the empty array is also what you\u2019ll get if you ask for nonsense, such as:<\/p>\n<pre class=\"lang:default decode:true\">SELECT name, category, abv from `beer-sample`\r\n\r\nWHERE brewery_id is not missing\r\n\r\nORDER BY name\r\n\r\nOFFSET -5\r\n\r\nLIMIT -10;\r\n\r\n<\/pre>\n<p>Wait\u2026.what?!?! \u00a0This query is asking to start 5 records before the beginning of the output set, and return no more than -10 records. \u00a05 records before the beginning is nothing. \u00a0And no more than -10 records is nothing. \u00a0 So you get\u2026.nothing!<\/p>\n<p>This behaviour is very convenient; it\u2019s clear when you\u2019re out of records, and it also plays nicely with a lot of other assumptions at different layers of software. If you\u2019ve ever used REST APIs that supported paging, this is generally how they work. For example, you can easily imagine a REST API endpoint that looks like this: \u00a0https:\/\/cool-app.com\/beers?limit=10&amp;page=6000. \u00a0 If you wrote such an endpoint in your back-end, you can easily see how that would generate a corresponding N1QL query, and even if the user gave you a funky page number, your endpoint would do the right thing.<\/p>\n<h2>But what if I want to know ahead of time how many pages there will be?<\/h2>\n<p>This is straightforward as well. \u00a0If we know that each page has n records in it, and we know the total number of records, then we can divide the total by n, take the ceiling of that number, and that will tell us how many potential pages are in Couchbase.<\/p>\n<pre class=\"lang:default decode:true\">SELECT CEIL(count(*) \/ 10) from `beer-sample`\r\n\r\nWHERE brewery_id is not missing\r\n\r\n<\/pre>\n<p>This yields on my local database 590. Because there are exactly 5,891 beer documents, that means there will be 589 sets of 10, and the final page will only have 1 document on it. Because 5,891 \/ 10 = 589.1, we use the N1QL\u00a0<u><a href=\"https:\/\/developer.couchbase.com\/documentation\/server\/current\/n1ql\/n1ql-language-reference\/numericfun.html\" target=\"_blank\" rel=\"noopener noreferrer\">CEIL function<\/a><\/u>\u00a0to get an integer number of pages, since whatever front-end application isn\u2019t going to display 0.1 of a page.<\/p>\n<p>Keep in mind that we still need the WHERE clause here, to cut down the documents to only beer documents, excluding brewery and other documents. \u00a0If the WHERE was missing, you\u2019d get the wrong number for sure.<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/www.couchbase.com\/community\/community-writers-program\/\"><em>This post is part of the Couchbase Community Writing Program<\/em><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>M. David Allen is a full-stack software engineer and entrepreneur who for more than a decade has been working with just about every different programming language and different type of database system he could get his hands on. \u00a0David has [&hellip;]<\/p>\n","protected":false},"author":53,"featured_media":13873,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[1816,1812],"tags":[2044],"ppma_author":[9026],"class_list":["post-3968","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-couchbase-server","category-n1ql-query","tag-paging"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v25.7.1 (Yoast SEO v25.7) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Paging Data Queries with N1QL - The Couchbase Blog<\/title>\n<meta name=\"description\" content=\"Dive into paging data queries with N1QL. Guest author David Allen shows us how to use a docker instance and learn about common paging use cases.\" \/>\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\/paging-data-queries-with-n1ql\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Paging Data Queries with N1QL\" \/>\n<meta property=\"og:description\" content=\"Dive into paging data queries with N1QL. Guest author David Allen shows us how to use a docker instance and learn about common paging use cases.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.couchbase.com\/blog\/paging-data-queries-with-n1ql\/\" \/>\n<meta property=\"og:site_name\" content=\"The Couchbase Blog\" \/>\n<meta property=\"article:published_time\" content=\"2017-08-25T08:09:33+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-06-14T00:23:17+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2017\/09\/Simple-Small-Headshot-450x300-compressed.png\" \/>\n\t<meta property=\"og:image:width\" content=\"450\" \/>\n\t<meta property=\"og:image:height\" content=\"300\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Laura Czajkowski, Developer Community 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=\"Laura Czajkowski, Developer Community Manager, Couchbase\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/paging-data-queries-with-n1ql\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/paging-data-queries-with-n1ql\/\"},\"author\":{\"name\":\"Laura Czajkowski, Developer Community Manager, Couchbase\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/5f1a0ece4e644bc8c037686fbc8f3220\"},\"headline\":\"Paging Data Queries with N1QL\",\"datePublished\":\"2017-08-25T08:09:33+00:00\",\"dateModified\":\"2025-06-14T00:23:17+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/paging-data-queries-with-n1ql\/\"},\"wordCount\":1325,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/paging-data-queries-with-n1ql\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png\",\"keywords\":[\"Paging\"],\"articleSection\":[\"Couchbase Server\",\"SQL++ \/ N1QL Query\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/paging-data-queries-with-n1ql\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/paging-data-queries-with-n1ql\/\",\"url\":\"https:\/\/www.couchbase.com\/blog\/paging-data-queries-with-n1ql\/\",\"name\":\"Paging Data Queries with N1QL - The Couchbase Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/paging-data-queries-with-n1ql\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/paging-data-queries-with-n1ql\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png\",\"datePublished\":\"2017-08-25T08:09:33+00:00\",\"dateModified\":\"2025-06-14T00:23:17+00:00\",\"description\":\"Dive into paging data queries with N1QL. Guest author David Allen shows us how to use a docker instance and learn about common paging use cases.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/paging-data-queries-with-n1ql\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/paging-data-queries-with-n1ql\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/paging-data-queries-with-n1ql\/#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\/paging-data-queries-with-n1ql\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.couchbase.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Paging Data Queries with N1QL\"}]},{\"@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\/5f1a0ece4e644bc8c037686fbc8f3220\",\"name\":\"Laura Czajkowski, Developer Community Manager, Couchbase\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/9deb07d5daaa00220534c31768bc4409\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/bc8eebaf25cbe39bc12fd7b1ef92550becc3953ab877a3f0285a59ec2d30b754?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/bc8eebaf25cbe39bc12fd7b1ef92550becc3953ab877a3f0285a59ec2d30b754?s=96&d=mm&r=g\",\"caption\":\"Laura Czajkowski, Developer Community Manager, Couchbase\"},\"description\":\"Laura Czajkowski is the Snr. Developer Community Manager at Couchbase overseeing the community. She\u2019s responsible for our monthly developer newsletter.\",\"url\":\"https:\/\/www.couchbase.com\/blog\/author\/laura-czajkowski\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Paging Data Queries with N1QL - The Couchbase Blog","description":"Dive into paging data queries with N1QL. Guest author David Allen shows us how to use a docker instance and learn about common paging use cases.","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\/paging-data-queries-with-n1ql\/","og_locale":"en_US","og_type":"article","og_title":"Paging Data Queries with N1QL","og_description":"Dive into paging data queries with N1QL. Guest author David Allen shows us how to use a docker instance and learn about common paging use cases.","og_url":"https:\/\/www.couchbase.com\/blog\/paging-data-queries-with-n1ql\/","og_site_name":"The Couchbase Blog","article_published_time":"2017-08-25T08:09:33+00:00","article_modified_time":"2025-06-14T00:23:17+00:00","og_image":[{"width":450,"height":300,"url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2017\/09\/Simple-Small-Headshot-450x300-compressed.png","type":"image\/png"}],"author":"Laura Czajkowski, Developer Community Manager, Couchbase","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Laura Czajkowski, Developer Community Manager, Couchbase","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.couchbase.com\/blog\/paging-data-queries-with-n1ql\/#article","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/paging-data-queries-with-n1ql\/"},"author":{"name":"Laura Czajkowski, Developer Community Manager, Couchbase","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/5f1a0ece4e644bc8c037686fbc8f3220"},"headline":"Paging Data Queries with N1QL","datePublished":"2017-08-25T08:09:33+00:00","dateModified":"2025-06-14T00:23:17+00:00","mainEntityOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/paging-data-queries-with-n1ql\/"},"wordCount":1325,"commentCount":0,"publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/paging-data-queries-with-n1ql\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png","keywords":["Paging"],"articleSection":["Couchbase Server","SQL++ \/ N1QL Query"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.couchbase.com\/blog\/paging-data-queries-with-n1ql\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.couchbase.com\/blog\/paging-data-queries-with-n1ql\/","url":"https:\/\/www.couchbase.com\/blog\/paging-data-queries-with-n1ql\/","name":"Paging Data Queries with N1QL - The Couchbase Blog","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/paging-data-queries-with-n1ql\/#primaryimage"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/paging-data-queries-with-n1ql\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png","datePublished":"2017-08-25T08:09:33+00:00","dateModified":"2025-06-14T00:23:17+00:00","description":"Dive into paging data queries with N1QL. Guest author David Allen shows us how to use a docker instance and learn about common paging use cases.","breadcrumb":{"@id":"https:\/\/www.couchbase.com\/blog\/paging-data-queries-with-n1ql\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.couchbase.com\/blog\/paging-data-queries-with-n1ql\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/paging-data-queries-with-n1ql\/#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\/paging-data-queries-with-n1ql\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.couchbase.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Paging Data Queries with N1QL"}]},{"@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\/5f1a0ece4e644bc8c037686fbc8f3220","name":"Laura Czajkowski, Developer Community Manager, Couchbase","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/9deb07d5daaa00220534c31768bc4409","url":"https:\/\/secure.gravatar.com\/avatar\/bc8eebaf25cbe39bc12fd7b1ef92550becc3953ab877a3f0285a59ec2d30b754?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/bc8eebaf25cbe39bc12fd7b1ef92550becc3953ab877a3f0285a59ec2d30b754?s=96&d=mm&r=g","caption":"Laura Czajkowski, Developer Community Manager, Couchbase"},"description":"Laura Czajkowski is the Snr. Developer Community Manager at Couchbase overseeing the community. She\u2019s responsible for our monthly developer newsletter.","url":"https:\/\/www.couchbase.com\/blog\/author\/laura-czajkowski\/"}]}},"authors":[{"term_id":9026,"user_id":53,"is_guest":0,"slug":"laura-czajkowski","display_name":"Laura Czajkowski, Developer Community Manager, Couchbase","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/bc8eebaf25cbe39bc12fd7b1ef92550becc3953ab877a3f0285a59ec2d30b754?s=96&d=mm&r=g","author_category":"","last_name":"Czajkowski","first_name":"Laura","job_title":"","user_url":"","description":"Laura Czajkowski is the Snr. Developer Community Manager at Couchbase overseeing the community. She\u2019s responsible for our monthly developer newsletter."}],"_links":{"self":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts\/3968","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\/53"}],"replies":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/comments?post=3968"}],"version-history":[{"count":0,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts\/3968\/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=3968"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/categories?post=3968"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/tags?post=3968"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=3968"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}