Skip to content ReleaseVezual Beta is in the Plugins Console

SQL

Your records.
Ready for real questions.

Build application screens, combine related facts and turn activity into useful summaries. Query structured data in the same engine as your vectors, relationships and searchable text.

Records to resultsSQL
app.recordsIllustrative data
idtitlestatus
01Getting startedpublished
02Release notesdraft
03API guidepublished
WHERE status = $1published
Only the records you need

Choose the fields. Apply a condition.
Use the result in your application.

A familiar query, connected to your data.

Everyday application queries

From a lookup
to a bigger picture.

Start with the record behind a screen. Add relationships and summaries as the question grows.

WHERE · ORDER BY

Find the records you need.

Filter by the fields that matter, sort the result and return the right records for an application screen.

JOIN

Bring related facts together.

Connect records across tables to answer questions that need more than one part of your data.

GROUP BY · COUNT · SUM

Turn activity into a summary.

Group records and calculate totals for reports, operational views and the decisions behind them.

SQL features depend on your configuration and supported query surface. Explore the SQL reference.

A query for the task

Express what
your app needs.

Use familiar SQL patterns to read and shape your records. Bind values as parameters and keep the result easy for your application to use.

Read supported SQL syntax

These examples assume tables named app.records and app.groups. No query runs on this page.

01 Filter and sort

Return a bounded set of records with a matching status.

                      SELECT id, title
FROM app.records
WHERE status = $1
ORDER BY id
LIMIT 20;
                    

Pass the status in the parameters array, rather than joining user input into the SQL string.

02 Join related tables

Add a group's label to the records that belong to it.

                      SELECT r.id, r.title, g.label
FROM app.records AS r
JOIN app.groups AS g
  ON r.group_id = g.id;
                    

Use explicit aliases so your application can distinguish columns returned from different tables.

03 Summarize records

Count the records in each status.

                      SELECT status, COUNT(*) AS total
FROM app.records
GROUP BY status;
                    

Filter input rows with WHERE; use HAVING when the condition applies to an aggregated group.

Understand the work

A result you can use.
A plan you can inspect.

See how a query reaches its answer before deciding what to tune.

01

Read the plan

Use EXPLAIN to inspect scans, indexes, joins and aggregation stages.

02

Narrow the work

Filter the input, return the columns you need and review where an index can help.

03

Measure the change

EXPLAIN ANALYZE executes the query and reports measurements so you can compare its work.

Build with OriginChainDB

Start with a table. Build with its answers.