AVG(text):
Quantify what you can't count

The PostgreSQL extension that brings LLMs into the database. Analyze text by meaning—using the SQL you already know.

Theme discovery—the 'Holy Grail': one query, 10K reviews, structured report.

Simplified. Full 3-prompt version in the story.

Theme Discovery Query
WITH themes AS (
SELECT llm_cluster_id(review_text) OVER () as theme_id, *
FROM reviews
)
SELECT
llm_agg(review_text, 'Name this theme: {1}') as theme_name,
COUNT(*) as volume,
AVG(rating) as avg_rating
FROM themes
GROUP BY theme_id;
Result
theme_namevolumeavg_rating
Battery Life1,2002.8
Shipping & Delivery8903.1
Quality / Defects6542.4
Customer Service4213.5

From Exact to Semantic

Two pillars of analytics—with semantic equivalents

OperationExact (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 — Math

Average revenue per region

llm_agg — Context

Summarize the essence of a group

Why Semantic SQL?

Semantic compute without the Python scripts

Zero Data Movement

Analysis happens where the data lives. One query replaces external ETL pipelines. No Python scripts.

Discover Without Schema

llm_cluster finds themes without defining categories first. No predefined schema required.

Parallel & Scalable

Parallel API calls. 100 rows: ~25s with 4 workers (vs 100s sequential).

Enrichment

JOIN semantic results with structured data—e.g., churn rates by complaint theme.

How It Works

Three steps from chaos to structure

1. Discover

llm_cluster finds themes automatically. Embed → Cluster → Label. No manual categorization.

2. Quantify

Standard GROUP BY, COUNT, and AVG on semantic IDs. Metrics you can trust.

3. Summarize

llm_agg synthesizes each group into a named summary.

For Developers

Choose the function that matches your complexity

Pattern = Input / Accumulator / Output. Semantic SQL is powered by the pg_llm extension.

LevelFunctionPatternUse Case
Level 1llm_compareI = A = OSame in/outPick the single best/worst item (e.g., most urgent ticket).
Level 2llm_accumulateI ≠ A = OStructured mergeExtract & merge structured data (e.g., count bugs, UI issues).
Level 3llm_parallel_accumulateI ≠ A ≠ OFull pipelineFull Map-Reduce-Finalize (e.g., executive summaries).

The Sarah Story

"Why are customers returning our new premium line?"

10,000 reviews (sample)

  • "Battery dies after 2 hours. Unacceptable for the price."
  • "Love it but shipping took 3 weeks. Product is great."
  • "Defective unit, screen flickers. Had to return."
  • "Customer service never replied. Still waiting."

One query produces this

theme_namevolumeavg_rating
Battery Life1,2002.8
Shipping & Delivery8903.1
Quality / Defects6542.4
Customer Service4213.5

See the Theme Discovery query in the demo above.

Common Use Cases

From support tickets to executive summaries

Support Triage

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.

Review Analysis

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.

Executive Summary

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.

Theme Discovery

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.

The Journey

A flywheel built on SQL

Distribution

Run it where your data lives—RDS, self-hosted, or managed Postgres.

Friction

One query, no scripts. Analysts adopt it themselves.

Conversion

SQL-first teams get results fast. They become advocates.

Expansion

More datasets, more use cases, more teams. The flywheel spins.

Clear Tiers

Free to start. Scale when you need managed hosting or compliance.

Open Source

Free

Free, powerful, but you own the ops.

  • Full pg_llm extension code
  • Native http provider support
  • Basic documentation
  • You manage API keys
  • You build RDS proxy if needed

Team

Coming soon/month

Deploy where your Postgres runs: native extension or managed proxy.

  • Managed Lambda Proxy for RDS
  • RDS? One line: llm.provider_url = 'api.pgllm.com'
  • Usage & cost dashboard
  • Shared caching (30–50% cost reduction)
  • Rate limiting protection

Enterprise

Contactsales

Safe, Compliant, and Predictable.

  • Private VPC deployment
  • Full audit logs
  • PII redaction
  • SLA guarantees
  • Bring Your Own Model

Common questions

Start quantifying your qualitativeness

Run AVG(text) in Postgres today. Open source. Free to start.

Open source. Free to start.

Stay Updated

Subscribe to our newsletter for the latest research insights, product updates, and AI innovations.