Theme discovery—the 'Holy Grail': one query, 10K reviews, structured report.
Simplified. Full 3-prompt version in the story.
WITH themes AS (SELECT llm_cluster_id(review_text) OVER () as theme_id, *FROM reviews)SELECTllm_agg(review_text, 'Name this theme: {1}') as theme_name,COUNT(*) as volume,AVG(rating) as avg_ratingFROM themesGROUP BY theme_id;
| theme_name | volume | avg_rating |
|---|---|---|
| Battery Life | 1,200 | 2.8 |
| Shipping & Delivery | 890 | 3.1 |
| Quality / Defects | 654 | 2.4 |
| Customer Service | 421 | 3.5 |
Two pillars of analytics—with semantic equivalents
| Operation | Exact (Traditional) | Semantic (Semantic SQL) |
|---|---|---|
Partitioning | GROUP BY — Identity (A = B)Group sales by region_id | llm_cluster — Similarity (A is like B)Discover themes without a schema |
Synthesis | AVG, SUM — MathAverage revenue per region | llm_agg — ContextSummarize the essence of a group |
Semantic compute without the Python scripts
Analysis happens where the data lives. One query replaces external ETL pipelines. No Python scripts.
llm_cluster finds themes without defining categories first. No predefined schema required.
Parallel API calls. 100 rows: ~25s with 4 workers (vs 100s sequential).
JOIN semantic results with structured data—e.g., churn rates by complaint theme.
Three steps from chaos to structure
llm_cluster finds themes automatically. Embed → Cluster → Label. No manual categorization.
Standard GROUP BY, COUNT, and AVG on semantic IDs. Metrics you can trust.
llm_agg synthesizes each group into a named summary.
Choose the function that matches your complexity
Pattern = Input / Accumulator / Output. Semantic SQL is powered by the pg_llm extension.
| Level | Function | Pattern | Use Case |
|---|---|---|---|
| Level 1 | llm_compare | I = A = OSame in/out | Pick the single best/worst item (e.g., most urgent ticket). |
| Level 2 | llm_accumulate | I ≠ A = OStructured merge | Extract & merge structured data (e.g., count bugs, UI issues). |
| Level 3 | llm_parallel_accumulate | I ≠ A ≠ OFull pipeline | Full Map-Reduce-Finalize (e.g., executive summaries). |
"Why are customers returning our new premium line?"
10,000 reviews (sample)
One query produces this
| theme_name | volume | avg_rating |
|---|---|---|
| Battery Life | 1,200 | 2.8 |
| Shipping & Delivery | 890 | 3.1 |
| Quality / Defects | 654 | 2.4 |
| Customer Service | 421 | 3.5 |
See the Theme Discovery query in the demo above.
From support tickets to executive summaries
THE CHALLENGE
Which ticket is most urgent? Manual triage across thousands of tickets.
WITH SEMANTIC SQL
llm_compare returns the single most critical ticket per department in one query.
THE CHALLENGE
Count bugs vs UI issues across 10K reviews. Impossible without scripting.
WITH SEMANTIC SQL
llm_accumulate extracts structured counts per product. Issue metrics in SQL.
THE CHALLENGE
Synthesize weekly reports from scattered emails. Hours of manual reading.
WITH SEMANTIC SQL
llm_parallel_accumulate produces 3-sentence summaries per week automatically.
THE CHALLENGE
What are the main themes in feedback? You'd need a research team.
WITH SEMANTIC SQL
One query from raw feedback to named themes and volumes.
A flywheel built on SQL
Run it where your data lives—RDS, self-hosted, or managed Postgres.
One query, no scripts. Analysts adopt it themselves.
SQL-first teams get results fast. They become advocates.
More datasets, more use cases, more teams. The flywheel spins.
Free to start. Scale when you need managed hosting or compliance.
Free, powerful, but you own the ops.
Deploy where your Postgres runs: native extension or managed proxy.
Safe, Compliant, and Predictable.
Run AVG(text) in Postgres today. Open source. Free to start.
Open source. Free to start.
Subscribe to our newsletter for the latest research insights, product updates, and AI innovations.