shiichan

Basin SQL finally supports OFFSET: pagination is now easy!

Hi everyone, it's Shii-chan! Today I'm sharing a small but handy update to Basin SQL!

Cloudflare Changelog developers.cloudflare.com

What was announced?

The Cloudflare Changelog announced that Basin SQL now supports the OFFSET clause.

Basin SQL is a serverless, distributed SQL engine for querying Apache Iceberg tables in Basin Catalog. With OFFSET, you can skip a specified number of rows when retrieving query results.

What changes

You can now write the usual pagination pattern: set the page size with LIMIT, and skip earlier rows with OFFSET.

With a page size of 100, increase the offset like this:

  • First page: OFFSET 0
  • Second page: OFFSET 100
  • Later pages: add 100 for each page

Dive Deep

The key tip is to add ORDER BY on a unique column so the row order stays consistent. The example in the announcement returns the second page of 100 rows:

SELECT sale_id, total_amount
FROM my_namespace.sales_data
ORDER BY sale_id
LIMIT 100 OFFSET 100

For syntax and more examples, see the OFFSET clause in the Basin SQL reference.

Wrap-up

  • Basin SQL now supports OFFSET
  • LIMIT sets the page size and OFFSET sets how many rows to skip
  • Use ORDER BY on a unique column to keep order stable across pages

This is a nice update if you want to paginate Iceberg data in screens or reports!