Skip to content

Feature Request: Support LIMIT ... OFFSET Syntax #62629

@murphyatwork

Description

@murphyatwork

Background
Currently, StarRocks supports LIMIT with an optional OFFSET keyword, but not the standard SQL form LIMIT <count> OFFSET <offset>. For example, the following query is not supported:

SELECT *
FROM t
ORDER BY id
LIMIT 10 OFFSET 20;

Problem
Users coming from PostgreSQL, MySQL, or other databases expect this syntax to work out of the box. The lack of support can cause confusion and requires rewriting queries to a StarRocks-specific style (e.g., LIMIT 20, 10).

Proposal
Add support for the SQL standard form:

LIMIT <count> OFFSET <offset>

This should be parsed and rewritten internally to the equivalent StarRocks syntax (LIMIT <offset>, <count>), ensuring compatibility without changing execution behavior.

Example

-- Standard SQL style
SELECT * FROM t ORDER BY id LIMIT 10 OFFSET 20;

-- StarRocks current style
SELECT * FROM t ORDER BY id LIMIT 20, 10;

Benefits

  • Improves compatibility with PostgreSQL/MySQL and other SQL engines.
  • Reduces migration friction for users.
  • Provides more intuitive readability for those familiar with the standard.

Compatibility
This is backward-compatible. Existing queries using the current StarRocks syntax will continue to work.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions