Queries, sorting and the lazy grid
Running JSON filter and SQL queries from the Studio, how header sorting turns into ORDER BY, and how the grid pages rows.
Filter and SQL tabs#
A query tab has a Filter | SQL toggle. Run with F5 or Ctrl/Cmd+Enter. The SQL box highlights
keywords, completes table and column names (Ctrl+Space) and marks the position of a syntax error from the server's
error.position ("Line 1, column 31").
The SQL the server accepts through /v1/query is this subset: SELECT * | COUNT(*) FROM <table> | <db>.<table> [WHERE ...] [ORDER BY ...] [LIMIT n] [OFFSET m], with AND OR NOT, parentheses, comparisons, IN, NOT IN, BETWEEN,
IS [NOT] NULL. Column lists, GROUP BY, LIKE, joins and writes are not supported through this endpoint. For the full SQL of the MySQL
front-end see the SQL reference.
Sorting by header#
Clicking a column header of a server result re-runs the query as SQL with ORDER BY <column> [DESC]: ascending, descending, off. The key
column sorts by _key. A sorted view pages by row offset (the cursor is the number of rows already returned), so any row is one
request away. Header sort needs a whole table or an SQL text without its own ORDER BY or OFFSET; a filter other than {} cannot
be turned into SQL.
A table's Data tab opens ORDER BY _key up to 200,000 rows. Above that it opens unsorted, with the note "unsorted: shard order, click a
column to sort" and a Sort by key button. Unsorted pages come in shard order, so keys are not ascending.
The lazy grid#
The grid is virtual over the table's total row count. It fetches pages as rows scroll into view, drops far pages (40 kept), cancels page
requests no longer in view, and for an unfiltered view jumps straight to any row using the per-shard counts of the table's stats
resource. Filtered and SQL views continue from known cursors and show "loaded X of N". A column chooser is available.
Checked in Chrome against a running server: a 120,000-row table opens sorted by key and Ctrl+End
loads row 120,000; a 250,000-row table opens unsorted and a jump to row 250,000 took 0.5 s. These are single manual checks, not benchmarks.
Cursor rules#
Cursors stay valid only while the data does not change. OFFSET m with a sorted cursor counts from the first row after the offset.