[ https://issues.apache.org/jira/browse/PHOENIX-2722?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15209654#comment-15209654 ]
ASF GitHub Bot commented on PHOENIX-2722: ----------------------------------------- Github user maryannxue commented on a diff in the pull request: https://github.com/apache/phoenix/pull/154#discussion_r57269833 --- Diff: phoenix-core/src/main/java/org/apache/phoenix/compile/QueryCompiler.java --- @@ -324,10 +328,13 @@ protected QueryPlan compileJoinQuery(StatementContext context, List<Object> bind QueryPlan plan = compileSingleFlatQuery(context, query, binds, asSubquery, !asSubquery && joinTable.isAllLeftJoin(), null, !table.isSubselect() && projectPKColumns ? tupleProjector : null, true); Expression postJoinFilterExpression = joinTable.compilePostFilterExpression(context, table); Integer limit = null; + Integer offset = null; if (!query.isAggregate() && !query.isDistinct() && query.getOrderBy().isEmpty()) { limit = plan.getLimit(); + offset = plan.getOffset(); } - HashJoinInfo joinInfo = new HashJoinInfo(projectedTable, joinIds, joinExpressions, joinTypes, starJoinVector, tables, fieldPositions, postJoinFilterExpression, limit); + HashJoinInfo joinInfo = new HashJoinInfo(projectedTable, joinIds, joinExpressions, joinTypes, + starJoinVector, tables, fieldPositions, postJoinFilterExpression, limit, offset); --- End diff -- The "limit" in HashJoinInfo is a little different than the original SQL semantics. It specifies the max number of rows returned by a HashJoinRegionScanner so that it doesn't do too much unnecessary work, and its max rows per region, so in the end the client might get more rows than needed and will do a final limit operation (all done by ScanPlan, don't worry). So, here, I think the limit should be "offset + limit" and there is no need to add an extra "offset" field to HashJoinInfo. Btw, change in serialization/deserialization of HashJoinInfo would cause incompatibility between different versions. > support mysql "limit,offset" clauses > ------------------------------------- > > Key: PHOENIX-2722 > URL: https://issues.apache.org/jira/browse/PHOENIX-2722 > Project: Phoenix > Issue Type: New Feature > Reporter: Ankit Singhal > Assignee: Ankit Singhal > Priority: Minor > Attachments: PHOENIX-2722.patch, PHOENIX-2722_formatted.patch > > > For serial query(query with “serial" hint or “limit" without "order by”), we > can limit each scan(using page filter) to “limit+offset” instead of limit > earlier. > And then, for all queries, we can forward the relevant client iterators to > the offset provided and then return the result. > syntax > {code} > [ LIMIT { count } ] > [ OFFSET start [ ROW | ROWS ] ] > [ FETCH { FIRST | NEXT } [ count ] { ROW | ROWS } ONLY ] > {code} > Some new keywords(OFFSET,FETCH,ROW, ROWS,ONLY) are getting introduced so > users might need to see that they are not using them as column name or > something. > WDYT, [~jamestaylor] -- This message was sent by Atlassian JIRA (v6.3.4#6332)