[ https://issues.apache.org/jira/browse/PHOENIX-4845?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16684397#comment-16684397 ]
Daniel Wong commented on PHOENIX-4845: -------------------------------------- I briefly surveyed some large code bases for their approaches and found these 2 which are nice and limits the need for cursor style syntax which I think is good for a first pass. The burden on the user is not a key then it is a offset. Decoupling from the key (much like cursor) provides most of the benefit that I was looking for in my discussion of a less column based query. MySQL, [https://dev.mysql.com/doc/refman/8.0/en/select.html] {code:java} SELECT * FROM tbl LIMIT 5,10; # Retrieve rows 6-15 {code} And Oracle, https://docs.oracle.com/javadb/10.8.3.0/ref/rrefsqljoffsetfetch.html {code:java} SELECT val FROM rownum_order_test ORDER BY val OFFSET 4 ROWS FETCH NEXT 4 ROWS ONLY; {code} Both of these i feel fit well and could be used. > Support using Row Value Constructors in OFFSET clause to support paging in > tables where the sort order of PK columns varies > --------------------------------------------------------------------------------------------------------------------------- > > Key: PHOENIX-4845 > URL: https://issues.apache.org/jira/browse/PHOENIX-4845 > Project: Phoenix > Issue Type: New Feature > Reporter: Thomas D'Silva > Priority: Major > Labels: DESC, SFDC > Attachments: PHOENIX-offset.txt > > > RVCs along with the LIMIT clause are useful for efficiently paging through > rows (see [http://phoenix.apache.org/paged.html]). This works well if the pk > columns are sorted ascending, we can always use the > operator to query for > the next batch of row. > However if the PK of a table is (A DESC, B DESC) we cannot use the following > query to page through the data > {code:java} > SELECT * FROM TABLE WHERE (A, B) > (?, ?) ORDER BY A DESC, B DESC LIMIT 20 > {code} > Since the rows are sorted by A desc and then by B descending we need change > the comparison order > {code:java} > SELECT * FROM TABLE WHERE (A, B) < (?, ?) ORDER BY A DESC, B DESC LIMIT 20 > {code} > If the PK of a table contains columns with mixed sort order for eg (A DESC, > B) then we cannot use RVC to page through data. > If we supported using RVCs in the offset clause we could use the offset to > set the start row of the scan. Clients would not have to have logic to > determine the comparison operator. This would also support paging through > data for tables where the PK columns are sorted in mixed order. > {code:java} > SELECT * FROM TABLE ORDER BY A DESC, B LIMIT 20 OFFSET (?,?) > {code} > We would only allow using the offset if the rows are ordered by the sort > order of the PK columns. > > FYI [~jfernando_sfdc] -- This message was sent by Atlassian JIRA (v7.6.3#76005)