Self-Service Analytics ResourcesBy SumboardDecember 4, 2026

What is a Query Library? Definition, Contents & How It Works

A query library is a shared catalog of checked, published queries. Charts and AI assistants reuse them, so the same metric is calculated the same way everywhere.

3 min read
What is a Query Library? Definition, Contents & How It Works

Query Library: One Published Query Behind Many Charts

A query library is a shared catalog of queries that a team has checked and published for reuse. A chart refers to a query in the library and does not hold its own copy of the SQL. When ten charts need "monthly revenue", all ten read the same query, so all ten show the same number.

In analytics the term means stored queries, not a code package. Developers also use "query library" for software that helps an application fetch data, which is a different thing.

What Does a Query Library Contain?

  • The query. The SQL, written once.
  • A name and a description. What the query returns and what it counts, in words a non-author can follow.
  • A status. Draft or published. Only published queries can be used.
  • A version history. Every publish is a new version, and earlier versions are kept.
  • A place. Folders or tags, so a query can be found again.
  • Where it is used. The charts and dashboards that read from it.

How Charts Use a Query Library

A chart attaches a published query and then adds its own grouping, filters and chart type on top. The calculation stays in the library.

When the query changes, the edit is published as a new version. In a library with version pinning, each chart stays on the version it was built with until someone moves it, so a definition never changes under a dashboard unnoticed.

Query Library and Semantic Layer

Both give a metric one definition. A query library stores finished queries that people wrote. A semantic layer stores measures, dimensions and joins, and writes the query itself for each request.

A query library is faster to set up because it uses the SQL a team already has. A semantic layer answers a wider range of questions and needs the data to be modelled first.

Query Libraries in Customer-Facing Analytics

When a product lets its customers build their own charts, the library is the set of calculations they are allowed to build from. The customer picks the metric and how to show it. The SQL stays with the team that owns it. The article on how a query library keeps every chart on the same number explains this in full.

The library controls the calculation, not who sees which rows. Limiting each customer to their own data is a separate rule: see multi-tenancy and row-level security.

Query Library Limits

A query library repeats whatever the query says. If the source data is wrong, every chart is wrong in the same way. It also does not decide what a metric should mean, and it needs an owner: without one, near-duplicate queries pile up and the library stops being the one place to look.

Frequently asked questions

Is a query library the same as saved queries?

▾
Not quite. Saved queries are usually personal copies that anyone can change. A query library adds a published status, a version history and a link from each chart to the query, so a correction is made once and its effect on dashboards is a deliberate choice.

Who should own a query library?

▾
The people who own the metrics, usually the data or product team. They decide what each query counts, publish changes and retire queries that are no longer used.

Can an AI assistant use a query library?

▾
Yes. An assistant can answer a question from a published query and does not have to write SQL from nothing. That ties its answer to a calculation a person has checked. It can still choose the wrong query for an unclear question, so the answer should show which query it used.