SQLDesk

Queries and parameters

A query is SQL against one data source, saved, with an owner and, if you like, a schedule.

Running one

Execute runs it and stores the result. Selecting part of the SQL runs only the selection, which is the fastest way to work on a piece of a long statement.

The result is kept. Everyone opening a dashboard sees the stored result and its age rather than causing a fresh run, which is why dashboards open quickly.

Seeing what a query will cost first

Tick Estimate cost beside LIMIT 1000 and Execute asks the engine what the query will cost before running it, then shows you: “Warehouse estimates 4.2 TB scanned, returning about 1,500,000 rows”, with Run it and Don’t run. The figure is the engine’s own planner, never a guess from the SQL.

What a query used

After a run, the line under the results shows what the engine says the query used. On Trino: “CPU 2 m 14 s · Read 5.0 GB”. The CPU figure is time across every worker, so it can be longer than the query took. Hover over it for the rest: rows read, peak memory, time queued and running, nodes, spill to disk, and Trino’s query id for its own web UI. BigQuery, Athena, Azure Data Explorer and CloudWatch show the bytes they scanned.

This costs nothing extra: the engine sends the figures back with the result. Engines that keep no such account show nothing here. SQLDesk does not run a second query to find out.

If an administrator has set a price on the data source, the line also shows roughly what the run cost, for example “≈ $0.08”, or “less than $0.01”. That figure is at their price. It is not a bill. The price is applied when the query runs, so a later change does not alter older results.

The line is on by default. An administrator can turn it off for a data source with Show what each run used. That hides it on older results too, and stops it reaching AI clients. What each engine reports is in the connectors page.

Parameters

Write {{ name }} in the SQL and a control appears. Press the settings icon beside it to choose what kind it is:

Text
Free text. Refused on publicly shared dashboards, because text spliced into SQL is how a shared link becomes a way to run arbitrary statements.
Number
A number, safely.
Dropdown
A fixed list you type. Safe to share, and usually what a text parameter should have been.
Query-based dropdown
The list comes from another query, so it stays current.
Date / date range
With relative options — last 7 days, this month — that move with the calendar.

Parameter values travel in the URL (?p_region=North), so a filtered view can be linked and bookmarked.

Scheduling

A query can refresh on a schedule so its dashboards are ready before anyone opens them. Pick the longest interval that is still useful — a five-minute refresh on a query nobody reads before Monday is paid for by your warehouse every five minutes.

Scheduled runs use the parameter defaults; there is nobody there to choose.

Permissions

You can query any data source your groups give full access to; view-only access shows results but runs no new SQL. With Enable experimental multiple owners support on (Settings → General), a query can be shared for editing with specific people; without that, others can run and view it but not change it.

History

History, in the query's ⋮ menu, lists every version of it: when it changed, who changed it, and what they changed. Pick one to see the diff — either what that version changed, or how it compares with the query as it is now, which is the question to ask before restoring.

Restore writes a new version that says what the old one said. Nothing is rewritten and nothing is deleted, so the version you restored stays in the list. A restore puts back the SQL, the name, the description, the parameters, the schedule and the tags — not the data source, and not whether the query is published or archived: those have their own controls, and an undo that quietly moved a query to another warehouse would be a surprise.

Anyone who can read the query can read its history; the restore is offered only to somebody who could have made the same edit by hand.

Taking the result away

Download sits beside the result: CSV, Excel or JSON. The same three are URLs, so a spreadsheet, a script or a scheduled job can fetch the latest stored result without a session and without a password:

GET /api/queries/<id>/results.csv?api_key=<the query's key>

The key belongs to the query, not to you. It is in Show API Key under the query's ⋮ menu, and it returns the stored result — the same one the dashboards see, with the same age — rather than running the SQL again. Regenerate makes a new one and anything holding the old one stops working that second, which is the point of having it.

A single visualization can be put in another page the same way, with Embed: an <iframe> pointing at /embed/query/<id>/visualization/<id>?api_key=…. Whoever opens that page sees the chart and nothing else — no SQL, no editor, no way into the rest of SQLDesk.

Fork copies the SQL, the parameters and the visualizations into a new query that belongs to you. It is the honest way to answer “the same, but for Europe” without editing somebody else's query and quietly changing what their dashboard means.

Snippets and formatting

Snippets are reusable fragments — Settings → Query Snippets — inserted by typing their trigger. Format Query tidies SQL for the dialects that support it.