How do I use paginate with 'cursors' in N1ql?NoSQL Query Language, UnQL? N1QL? CouchBase, C embedded libraryObtaining last revisions in Couchbase with N1QLCouchbase N1QL query against existing viewdefault object in N1QL resultsSelect multiple counts for each day in date range using N1QLN1QL query on arrayHow to query documents which are arraysCouchbase Index and N1QL QueryUsing Couchbase String functions in N1QL responseOffset results of children nodes from N1QL Analytics query

ESTA Travel not Authorized. Accepted twice before!

BIP-23 criticism: Is bitcoin PoW actually sha256+merkleGeneration? Or have I misunderstood coinbase/append?

What does a Nintendo Game Boy do when turned on without a game cartridge inserted?

Why is there an extra "t" in Lemmatization?

Why don't humans perceive sound waves as twice the frequency they are?

Why teach C using scanf without talking about command line arguments?

Longtable of size textwidth exceeds right margin

TCP connections hang during handshake

Does unblocking power bar outlets through short extension cords increase fire risk?

why neutral does not shock. how can a neutral be neutral in ac current?

Aren't all schwa sounds literally /ø/?

Can a creature sustain itself by eating its own severed body parts?

Improving an O(N^2) function (all entities iterating over all other entities)

Linux ext4 restore file and directory access rights after bad backup/restore

When we are talking about black hole evaporation - what exactly happens?

"This used to be my phone number"

Does the Bracer of Flying Daggers really let a thief make 4 attacks per round?

Which modern firearm should a time traveler bring to be easily reproducible for a historic civilization?

Is it ethical to tell my teaching assistant that I like them?

Redirection operator, standard input and command parameters

Why is this guy handcuffed censored?

What is really the difference between uniform velocity and constant velocity?

How was Luke's prosthetic hand in Episode V filmed?

Will copper pour help on my single-layer PCB?



How do I use paginate with 'cursors' in N1ql?


NoSQL Query Language, UnQL? N1QL? CouchBase, C embedded libraryObtaining last revisions in Couchbase with N1QLCouchbase N1QL query against existing viewdefault object in N1QL resultsSelect multiple counts for each day in date range using N1QLN1QL query on arrayHow to query documents which are arraysCouchbase Index and N1QL QueryUsing Couchbase String functions in N1QL responseOffset results of children nodes from N1QL Analytics query






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








4















I need to paginate a Couchbase N1ql Query.



I am aware of pagination with OFFSET, but it is more efficient to designate the start and end point.



I see documentation about startkey_docid, but none about how to us this in N1ql.



How do I paginate with cursors, or something similar, in N1ql?










share|improve this question






























    4















    I need to paginate a Couchbase N1ql Query.



    I am aware of pagination with OFFSET, but it is more efficient to designate the start and end point.



    I see documentation about startkey_docid, but none about how to us this in N1ql.



    How do I paginate with cursors, or something similar, in N1ql?










    share|improve this question


























      4












      4








      4


      1






      I need to paginate a Couchbase N1ql Query.



      I am aware of pagination with OFFSET, but it is more efficient to designate the start and end point.



      I see documentation about startkey_docid, but none about how to us this in N1ql.



      How do I paginate with cursors, or something similar, in N1ql?










      share|improve this question
















      I need to paginate a Couchbase N1ql Query.



      I am aware of pagination with OFFSET, but it is more efficient to designate the start and end point.



      I see documentation about startkey_docid, but none about how to us this in N1ql.



      How do I paginate with cursors, or something similar, in N1ql?







      couchbase n1ql database-cursor






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 26 at 12:34







      Joshua Fox

















      asked Mar 26 at 10:18









      Joshua FoxJoshua Fox

      8,65011 gold badges52 silver badges83 bronze badges




      8,65011 gold badges52 silver badges83 bronze badges






















          2 Answers
          2






          active

          oldest

          votes


















          1














          Look into "keyset pagination", a general technique for improving pagination performance by leveraging the index instead of using offset. A commonly cited article on the topic is Markus Winand's "We need tool support for keyset pagination."



          For a Couchbase-specific example that uses N1QL, see Keshav Murthy's article "Database Pagination: Using OFFSET and Keyset in N1QL."






          share|improve this answer























          • Makes sense but what about startkey_docid? It seems like a different approach, also efficient. Is that available for me to use?

            – Joshua Fox
            Mar 27 at 13:07






          • 1





            @JoshuaFox startkey_docid is only for views, not available for N1QL.

            – dnault
            Mar 27 at 17:00


















          2














          N1QL does not support cursors. Behind the scenes, every query sent to the query engine is a separate HTTP request. There is simply no continuity between queries, and therefore no concept of cursors is supported.






          share|improve this answer























          • Ok, so how do I do pagination (other than with OFFSET, which is inefficient)?

            – Joshua Fox
            Mar 26 at 12:34











          • If you are going to paginate using the database, OFFSET and LIMIT are your only choices. If that won't do, you'll have to pull the entire result into a higher level of the system (the app server, maybe?) and paginate from there. You can make this second option less heavyweight by fetching doc ids rather than complete documents and filling in the document contents only when they are needed.

            – Johan Larson
            Mar 26 at 13:00











          • Thank you . It seems that Pagination is an important feature for pretty much any application. Do you know why only the OFFSET is offered here? Couchbase does have startkey_docid, so clearly the Couchbase designers are aware of this.

            – Joshua Fox
            Mar 26 at 15:12






          • 1





            It's true that Couchbase does not support cursors, but "keyset pagination" might give better performance than paginating with OFFSET and LIMIT. I put some links in another answer.

            – dnault
            Mar 26 at 18:38







          • 1





            The REST API that supports startkey_docid is very inefficient with large data sets, it's really only good for getting the first thousand or so keys. N1QL can work with "primary indexes" which allow you to search using, "meta().id > x and meta().id < y". Primary indexes should be used with extreme caution, since they can lead to full database scans if you aren't careful.

            – EbenH
            Mar 29 at 17:18













          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55354659%2fhow-do-i-use-paginate-with-cursors-in-n1ql%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          Look into "keyset pagination", a general technique for improving pagination performance by leveraging the index instead of using offset. A commonly cited article on the topic is Markus Winand's "We need tool support for keyset pagination."



          For a Couchbase-specific example that uses N1QL, see Keshav Murthy's article "Database Pagination: Using OFFSET and Keyset in N1QL."






          share|improve this answer























          • Makes sense but what about startkey_docid? It seems like a different approach, also efficient. Is that available for me to use?

            – Joshua Fox
            Mar 27 at 13:07






          • 1





            @JoshuaFox startkey_docid is only for views, not available for N1QL.

            – dnault
            Mar 27 at 17:00















          1














          Look into "keyset pagination", a general technique for improving pagination performance by leveraging the index instead of using offset. A commonly cited article on the topic is Markus Winand's "We need tool support for keyset pagination."



          For a Couchbase-specific example that uses N1QL, see Keshav Murthy's article "Database Pagination: Using OFFSET and Keyset in N1QL."






          share|improve this answer























          • Makes sense but what about startkey_docid? It seems like a different approach, also efficient. Is that available for me to use?

            – Joshua Fox
            Mar 27 at 13:07






          • 1





            @JoshuaFox startkey_docid is only for views, not available for N1QL.

            – dnault
            Mar 27 at 17:00













          1












          1








          1







          Look into "keyset pagination", a general technique for improving pagination performance by leveraging the index instead of using offset. A commonly cited article on the topic is Markus Winand's "We need tool support for keyset pagination."



          For a Couchbase-specific example that uses N1QL, see Keshav Murthy's article "Database Pagination: Using OFFSET and Keyset in N1QL."






          share|improve this answer













          Look into "keyset pagination", a general technique for improving pagination performance by leveraging the index instead of using offset. A commonly cited article on the topic is Markus Winand's "We need tool support for keyset pagination."



          For a Couchbase-specific example that uses N1QL, see Keshav Murthy's article "Database Pagination: Using OFFSET and Keyset in N1QL."







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 26 at 18:34









          dnaultdnault

          4,2161 gold badge19 silver badges40 bronze badges




          4,2161 gold badge19 silver badges40 bronze badges












          • Makes sense but what about startkey_docid? It seems like a different approach, also efficient. Is that available for me to use?

            – Joshua Fox
            Mar 27 at 13:07






          • 1





            @JoshuaFox startkey_docid is only for views, not available for N1QL.

            – dnault
            Mar 27 at 17:00

















          • Makes sense but what about startkey_docid? It seems like a different approach, also efficient. Is that available for me to use?

            – Joshua Fox
            Mar 27 at 13:07






          • 1





            @JoshuaFox startkey_docid is only for views, not available for N1QL.

            – dnault
            Mar 27 at 17:00
















          Makes sense but what about startkey_docid? It seems like a different approach, also efficient. Is that available for me to use?

          – Joshua Fox
          Mar 27 at 13:07





          Makes sense but what about startkey_docid? It seems like a different approach, also efficient. Is that available for me to use?

          – Joshua Fox
          Mar 27 at 13:07




          1




          1





          @JoshuaFox startkey_docid is only for views, not available for N1QL.

          – dnault
          Mar 27 at 17:00





          @JoshuaFox startkey_docid is only for views, not available for N1QL.

          – dnault
          Mar 27 at 17:00













          2














          N1QL does not support cursors. Behind the scenes, every query sent to the query engine is a separate HTTP request. There is simply no continuity between queries, and therefore no concept of cursors is supported.






          share|improve this answer























          • Ok, so how do I do pagination (other than with OFFSET, which is inefficient)?

            – Joshua Fox
            Mar 26 at 12:34











          • If you are going to paginate using the database, OFFSET and LIMIT are your only choices. If that won't do, you'll have to pull the entire result into a higher level of the system (the app server, maybe?) and paginate from there. You can make this second option less heavyweight by fetching doc ids rather than complete documents and filling in the document contents only when they are needed.

            – Johan Larson
            Mar 26 at 13:00











          • Thank you . It seems that Pagination is an important feature for pretty much any application. Do you know why only the OFFSET is offered here? Couchbase does have startkey_docid, so clearly the Couchbase designers are aware of this.

            – Joshua Fox
            Mar 26 at 15:12






          • 1





            It's true that Couchbase does not support cursors, but "keyset pagination" might give better performance than paginating with OFFSET and LIMIT. I put some links in another answer.

            – dnault
            Mar 26 at 18:38







          • 1





            The REST API that supports startkey_docid is very inefficient with large data sets, it's really only good for getting the first thousand or so keys. N1QL can work with "primary indexes" which allow you to search using, "meta().id > x and meta().id < y". Primary indexes should be used with extreme caution, since they can lead to full database scans if you aren't careful.

            – EbenH
            Mar 29 at 17:18















          2














          N1QL does not support cursors. Behind the scenes, every query sent to the query engine is a separate HTTP request. There is simply no continuity between queries, and therefore no concept of cursors is supported.






          share|improve this answer























          • Ok, so how do I do pagination (other than with OFFSET, which is inefficient)?

            – Joshua Fox
            Mar 26 at 12:34











          • If you are going to paginate using the database, OFFSET and LIMIT are your only choices. If that won't do, you'll have to pull the entire result into a higher level of the system (the app server, maybe?) and paginate from there. You can make this second option less heavyweight by fetching doc ids rather than complete documents and filling in the document contents only when they are needed.

            – Johan Larson
            Mar 26 at 13:00











          • Thank you . It seems that Pagination is an important feature for pretty much any application. Do you know why only the OFFSET is offered here? Couchbase does have startkey_docid, so clearly the Couchbase designers are aware of this.

            – Joshua Fox
            Mar 26 at 15:12






          • 1





            It's true that Couchbase does not support cursors, but "keyset pagination" might give better performance than paginating with OFFSET and LIMIT. I put some links in another answer.

            – dnault
            Mar 26 at 18:38







          • 1





            The REST API that supports startkey_docid is very inefficient with large data sets, it's really only good for getting the first thousand or so keys. N1QL can work with "primary indexes" which allow you to search using, "meta().id > x and meta().id < y". Primary indexes should be used with extreme caution, since they can lead to full database scans if you aren't careful.

            – EbenH
            Mar 29 at 17:18













          2












          2








          2







          N1QL does not support cursors. Behind the scenes, every query sent to the query engine is a separate HTTP request. There is simply no continuity between queries, and therefore no concept of cursors is supported.






          share|improve this answer













          N1QL does not support cursors. Behind the scenes, every query sent to the query engine is a separate HTTP request. There is simply no continuity between queries, and therefore no concept of cursors is supported.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 26 at 12:04









          Johan LarsonJohan Larson

          1,7021 gold badge9 silver badges14 bronze badges




          1,7021 gold badge9 silver badges14 bronze badges












          • Ok, so how do I do pagination (other than with OFFSET, which is inefficient)?

            – Joshua Fox
            Mar 26 at 12:34











          • If you are going to paginate using the database, OFFSET and LIMIT are your only choices. If that won't do, you'll have to pull the entire result into a higher level of the system (the app server, maybe?) and paginate from there. You can make this second option less heavyweight by fetching doc ids rather than complete documents and filling in the document contents only when they are needed.

            – Johan Larson
            Mar 26 at 13:00











          • Thank you . It seems that Pagination is an important feature for pretty much any application. Do you know why only the OFFSET is offered here? Couchbase does have startkey_docid, so clearly the Couchbase designers are aware of this.

            – Joshua Fox
            Mar 26 at 15:12






          • 1





            It's true that Couchbase does not support cursors, but "keyset pagination" might give better performance than paginating with OFFSET and LIMIT. I put some links in another answer.

            – dnault
            Mar 26 at 18:38







          • 1





            The REST API that supports startkey_docid is very inefficient with large data sets, it's really only good for getting the first thousand or so keys. N1QL can work with "primary indexes" which allow you to search using, "meta().id > x and meta().id < y". Primary indexes should be used with extreme caution, since they can lead to full database scans if you aren't careful.

            – EbenH
            Mar 29 at 17:18

















          • Ok, so how do I do pagination (other than with OFFSET, which is inefficient)?

            – Joshua Fox
            Mar 26 at 12:34











          • If you are going to paginate using the database, OFFSET and LIMIT are your only choices. If that won't do, you'll have to pull the entire result into a higher level of the system (the app server, maybe?) and paginate from there. You can make this second option less heavyweight by fetching doc ids rather than complete documents and filling in the document contents only when they are needed.

            – Johan Larson
            Mar 26 at 13:00











          • Thank you . It seems that Pagination is an important feature for pretty much any application. Do you know why only the OFFSET is offered here? Couchbase does have startkey_docid, so clearly the Couchbase designers are aware of this.

            – Joshua Fox
            Mar 26 at 15:12






          • 1





            It's true that Couchbase does not support cursors, but "keyset pagination" might give better performance than paginating with OFFSET and LIMIT. I put some links in another answer.

            – dnault
            Mar 26 at 18:38







          • 1





            The REST API that supports startkey_docid is very inefficient with large data sets, it's really only good for getting the first thousand or so keys. N1QL can work with "primary indexes" which allow you to search using, "meta().id > x and meta().id < y". Primary indexes should be used with extreme caution, since they can lead to full database scans if you aren't careful.

            – EbenH
            Mar 29 at 17:18
















          Ok, so how do I do pagination (other than with OFFSET, which is inefficient)?

          – Joshua Fox
          Mar 26 at 12:34





          Ok, so how do I do pagination (other than with OFFSET, which is inefficient)?

          – Joshua Fox
          Mar 26 at 12:34













          If you are going to paginate using the database, OFFSET and LIMIT are your only choices. If that won't do, you'll have to pull the entire result into a higher level of the system (the app server, maybe?) and paginate from there. You can make this second option less heavyweight by fetching doc ids rather than complete documents and filling in the document contents only when they are needed.

          – Johan Larson
          Mar 26 at 13:00





          If you are going to paginate using the database, OFFSET and LIMIT are your only choices. If that won't do, you'll have to pull the entire result into a higher level of the system (the app server, maybe?) and paginate from there. You can make this second option less heavyweight by fetching doc ids rather than complete documents and filling in the document contents only when they are needed.

          – Johan Larson
          Mar 26 at 13:00













          Thank you . It seems that Pagination is an important feature for pretty much any application. Do you know why only the OFFSET is offered here? Couchbase does have startkey_docid, so clearly the Couchbase designers are aware of this.

          – Joshua Fox
          Mar 26 at 15:12





          Thank you . It seems that Pagination is an important feature for pretty much any application. Do you know why only the OFFSET is offered here? Couchbase does have startkey_docid, so clearly the Couchbase designers are aware of this.

          – Joshua Fox
          Mar 26 at 15:12




          1




          1





          It's true that Couchbase does not support cursors, but "keyset pagination" might give better performance than paginating with OFFSET and LIMIT. I put some links in another answer.

          – dnault
          Mar 26 at 18:38






          It's true that Couchbase does not support cursors, but "keyset pagination" might give better performance than paginating with OFFSET and LIMIT. I put some links in another answer.

          – dnault
          Mar 26 at 18:38





          1




          1





          The REST API that supports startkey_docid is very inefficient with large data sets, it's really only good for getting the first thousand or so keys. N1QL can work with "primary indexes" which allow you to search using, "meta().id > x and meta().id < y". Primary indexes should be used with extreme caution, since they can lead to full database scans if you aren't careful.

          – EbenH
          Mar 29 at 17:18





          The REST API that supports startkey_docid is very inefficient with large data sets, it's really only good for getting the first thousand or so keys. N1QL can work with "primary indexes" which allow you to search using, "meta().id > x and meta().id < y". Primary indexes should be used with extreme caution, since they can lead to full database scans if you aren't careful.

          – EbenH
          Mar 29 at 17:18

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55354659%2fhow-do-i-use-paginate-with-cursors-in-n1ql%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

          155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해