Skip to content

Tools

SQL Query

Query and update Redis or Valkey keys with Varc's bounded SQL workbench.

SQL Query gives you a familiar way to explore and change Redis without translating every task into Redis commands. Varc exposes the current database as one logical redis table, plans bounded SELECT and UPDATE statements, and reports typed rows and mutation progress in the same results pane.

Task Action
Run the active query Choose Run or press Mod+Enter
Explain the active query Choose Explain
Save the active query Choose Save
Open a saved query Choose Saved queries
Open a result in the value viewer Activate its exact-value action

Mod means Command on macOS and Ctrl on Windows and Linux.

Open SQL Query

Connect to a Redis or Valkey profile, then choose Query → SQL Query in the Dock. SQL Query always runs against the database currently selected in that workspace. Redis Cluster supports database 0 only.

The first local tab is named Untitled-1 and starts with this query:

SELECT key, type, ttl_ms
FROM redis
WHERE key LIKE '%'
LIMIT 100;

Run your first query

Replace the key pattern with a namespace you recognise, then choose Run:

SELECT key, type, ttl_ms
FROM redis
WHERE key LIKE 'user:%'
ORDER BY ttl_ms ASC NULLS LAST
LIMIT 100;

The results pane reports the current state and progress. Matching rows appear in pages while the query runs. Activate a row to open that exact binary-safe key in the existing value viewer; Varc does not reconstruct the key from displayed text.

Run a query, inspect its progress, then activate a row to continue in the value viewer.

If no key matches, the results pane says No matching rows. A parser or type error appears at its source range in the editor and in the editor footer; the query does not start until preparation succeeds.

Write with editor guidance

The editor exposes completion metadata for the redis table, its five columns, supported clauses, type-aware Redis functions, and the five aggregates. Diagnostics and source ranges come from the same compiler that prepares the query for execution.

Completion documents the supported dialect; diagnostics identify unsupported or invalid SQL before execution.

Update keys in place

UPDATE can change a key name, scalar value, TTL, or one of Redis’s collection types without leaving the editor:

UPDATE redis
SET value = CAST(value AS INTEGER) + 1,
    ttl_ms = 60000
WHERE key = 'counter:visits'
RETURNING key, type, ttl_ms, value
LIMIT 1;

Run first performs read-only discovery, evaluation, and any required Cluster same-slot preflight. Varc then asks for single-use approval bound to that exact source, run, workspace, topology, and mutation plan. Editing the source, reconnecting, closing the tab, or starting another run invalidates the approval.

Without RETURNING, the results pane reports the number of updated keys. With RETURNING, each committed key produces an ordinary result row that opens the final key name.

Start with Update keys with SQL for mutable columns, TTL behavior, collection functions, Cluster renames, MCP access, and first-error semantics.

Work with tabs and recent queries

Choose the plus button to create another local query tab. Tabs can be activated and closed independently. An unsaved edit adds a dirty indicator.

Every admitted run is added to Recent history with its eventual terminal state. Selecting one loads its source into a safe draft so you can rerun or adapt it. Recent history belongs only to the current SQL tool session, keeps at most 50 executions, and is never persisted.

Local tabs are drafts, not saved records. If you close a dirty tab, Varc asks whether to Save, Don’t Save, or Cancel. Closing an unchanged draft needs no prompt.

Save and reopen a query

Choose Save. The first save asks for a name; later saves update the same record. Choose Saved queries to open a profile-scoped record, rename it, move it up or down, or delete it.

Saved SQL is local to this machine and scoped to the connection profile. See Saved queries for privacy, quotas, conflicts, and limits.

Query and plan examples

These statements copy into the editor:

SELECT key,
       CASE
         WHEN TRY_CAST(value AS INTEGER) BETWEEN 0 AND 10 THEN 'low'
         ELSE 'other'
       END AS band
FROM redis
WHERE type = 'string'
LIMIT 100;
SELECT type, COUNT(*) AS keys, AVG(ttl_ms) AS avg_ttl
FROM redis
GROUP BY type
HAVING COUNT(*) >= 1
ORDER BY keys DESC
LIMIT 20;
EXPLAIN SELECT type, COUNT(*)
FROM redis
WHERE key LIKE 'user:%'
GROUP BY type;

EXPLAIN shows a sanitized semantic plan and performs no Redis I/O. Grouped result rows are synthetic: they do not open a key in the value viewer.