Querying in the Editor

Use the Prism editor to write SQL, run queries, view tables or charts, and save/share results.


Editor Basics

  • Schema browser: Explore tables and columns with types and descriptions.
  • SQL editor: Write or paste SQL; use templates as a starting point.
  • Run: Executes the query and shows a results table; switch to chart for simple visualizations.
  • Save: Name your query, add a description, and choose visibility (private or organization).

Parameters

  • Use named parameters to reuse queries across date ranges or segments.
  • Example: created_at BETWEEN :start AND :end
  • The UI prompts for parameter values before running or scheduling.

Best Practices

  • Filter early by date range and status (for example, status = 'succeeded').
  • Select only needed columns; avoid SELECT * for large tables.
  • Aggregate when possible (for example, use GROUP BY to summarize).
  • Preview with LIMIT before running full queries.

Note: If your query has no LIMIT, Prism may add one automatically.


Charts

  • Quick charts let you visualize common aggregations (line/bar).
  • Choose an x-axis (for example, a date) and one or more metrics to plot.
  • Charts are intended for lightweight exploration. For full dashboards, export results to your BI tool.

Save, Share, and Organize

  • Save queries for personal or organization-wide use.
  • Add tags in the name or description to make searches easier (for example, “MRR”, “payouts”).
  • Create a folder structure if available in your plan to group related analyses.

Common Patterns (Snippets)

  • Daily totals
SELECT date_trunc('day', created_at) AS day, sum(amount) AS gross
FROM analytics.payments
WHERE status = 'succeeded' AND created_at >= :start AND created_at < :end
GROUP BY 1
ORDER BY 1;
  • Payment method mix
SELECT payment_method_type, sum(amount) AS gross
FROM analytics.payments
WHERE status = 'succeeded' AND created_at >= :start AND created_at < :end
GROUP BY 1
ORDER BY gross DESC;
  • Refund rate
WITH charges AS (
  SELECT count(*) AS cnt
  FROM analytics.payments
  WHERE status = 'succeeded' AND created_at >= :start AND created_at < :end
),
refunds AS (
  SELECT count(*) AS cnt
  FROM analytics.refunds
  WHERE created_at >= :start AND created_at < :end
)
SELECT refunds.cnt::decimal / nullif(charges.cnt, 0) AS refund_rate;

See more examples: /docs/prism-templates


Last updated: 2025-10-20