Running a Query
Once a query is saved you can run it from the Queries list, from the editor, or wherever it appears on a dashboard.
Running with a form
If a query has form variables, Kvery shows a form before running. Fill in the fields and submit to execute the query with those values. Field types include text, numbers, dates, and special inputs such as checkboxes, radio buttons, and selects.
Every form is sent with the same button: its label is the query's Form button text ("Send" by default) and its colour the Form button color (Green by default). For a query that writes data, set a label that names the action, and turn on Confirm enabled?: the form then asks for confirmation ("Are you sure?" / "The operation cannot be undone!" by default) before it is sent. After the run a write query shows its Successful operation text when it affected at least one row, and its Unsuccessful operation text when it ran but affected no row. These settings are in the query's Form settings, see Query settings.
How the result is loaded
The run page in the app opens once the query has run. A shared link page opens right away with a loading indicator and shows the result as soon as it is ready, and Save and Run in the editor shows the result next to the editor in the same way. The tiles of a dashboard load their results each on its own.
The header of the run page shows the description of the query and, depending on your rights, Edit query, Add to board (see Board), the Internal note (see Internal notes) and, for a read query with a result, Fullscreen.
Refreshing the result
Next to the layout selector, the run page of a read query has a refresh selector: No refresh, 5 sec, 15 sec, 30 sec or 60 sec. With an interval chosen, the table reloads its rows at that interval while the page is open, and the layout selector is hidden until you choose No refresh again; a refresh is skipped while you have the details of a row or an expanded JSON value open, and the selector is then replaced by a red "No refresh" until the next refresh runs. When the query has an Auto refresh table (sec) setting (see Query settings), the page reloads the rows at that interval and shows "Auto refresh:" with it instead of the selectors. A refresh that fails (for example because of a network error) keeps the rows shown, and the next interval tries again.
In a dashboard tile, a Refresh icon next to the
description reloads the rows. A page opened with ?iframe=1 (see
Embedding in a frame) and a shared
link opened in the mobile app show no layout and refresh
selectors.
Where results appear
The result is rendered using the query's saved layout:
- a table (sortable, searchable, paginated),
- a card (the columns of a single-row result as label / value pairs; offered when the result has exactly one row),
- a chart (Chart view), or a chart with the table below it (Chart and table view), or
- the Simple view of a one-row result (see Results).
Timeouts
Queries run under a timeout (100 seconds by default). If a query exceeds it, the
execution is stopped and the error is recorded in the logs.
For heavy workloads use scheduling, and add LIMIT/pagination
where possible. See
Supported databases.
When a run fails
- The SQL fails — the page shows an error: the database's message to the
editors of the query (for a timeout reported by the database, "Query execution
timeout exceeded (100s)") and "Something went wrong!" to everyone else. A query
with
ON ERROR RETURNshows its own message instead (see Controlling the response). The page answers with HTTP status 500, or with the status the query sets. - A value with Kvery's query syntax — a request value that contains syntax of the query engine is refused with "A parameter value is not allowed: it contains syntax of the query engine (statement blocks, comment markers, snippet() or a directive such as return() or GET('...'))." (HTTP 400; see How values are inserted).
- Member tags — a member whose member tags do not allow the query gets HTTP 401.
- IP whitelist — a run that the group's IP whitelist does not allow gets HTTP 403.
- Plan — when the group's plan is not active, or the group holds more queries than its plan allows, its queries do not run: the run page in the app opens the Packages screen instead, elsewhere (dashboard tiles, shared links, the API) the answer is HTTP 404 with "You have reached the package limit. Subscribe or upgrade to a larger package!" (see Plans and limits).
Result caching
A read query can use a result cache when you set a cache expiration (in seconds) in its settings: until a stored result expires, repeated runs with the same values return it instantly. A result served from the cache is marked "(cached)" next to the description of the run page in the app, and Save and Run in the editor always runs the query against the database. You can clear a query's cache when you need fresh data. See Export and cache.