---
title: "What is a query decorator?"
description: "A query decorator names a reusable query you can call from an agent, from HTTP, or from another column."
url: "https://pixeltable.com/learn/what-is-a-query-decorator"
updated: "2026-09-29"
vertical: "Serving"
doc: "https://docs.pixeltable.com/overview/quick-start"
---

# What is a query decorator?

A query decorator names a reusable query you can call from an agent, from HTTP, or from another column.

Updated: 2026-09-29


## On this page

- [How it works](https://pixeltable.com/learn/what-is-a-query-decorator#how-it-works)
- [What it is not](https://pixeltable.com/learn/what-is-a-query-decorator#what-it-is-not)
- [Comparison](https://pixeltable.com/learn/what-is-a-query-decorator#comparison)
- [Where Pixeltable fits](https://pixeltable.com/learn/what-is-a-query-decorator#where-pixeltable-fits)
- [Questions](https://pixeltable.com/learn/what-is-a-query-decorator#questions)

## How it works {#how-it-works}


- The function states filters, order, and limit.
- Callers pass arguments.
- The same function is a tool, a route, or a column input.

## What it is not {#what-it-is-not}

It is not ad-hoc SQL pasted into every handler.

## query decorator: this, and the thing it is confused with {#comparison}

|  | This | Not this |
| --- | --- | --- |
| Named | Yes | A string in a handler |
| Callers | Agents, HTTP, columns | One route |
| Returns | Rows | An untyped payload you reshape |

## Where Pixeltable fits {#where-pixeltable-fits}

Pixeltable uses @pxt.query for that function, then add_query_route or pxt.tools() to expose it.

## Questions {#questions}

### How does query decorator work? {#faq-1}

The function states filters, order, and limit. Callers pass arguments. The same function is a tool, a route, or a column input.

### What is query decorator often confused with? {#faq-2}

It is not ad-hoc SQL pasted into every handler.

## In the blog

- [The @pxt.query Decorator: Building Reusable Database Queries for AI Agents and RAG Systems](https://pixeltable.com/blog/reusable-query-patterns-pxt-query)

## Related

- [Documentation](https://docs.pixeltable.com/overview/quick-start)
- [The @pxt.query Decorator: Building Reusable Database Queries for AI Agents and RAG Systems](https://pixeltable.com/blog/reusable-query-patterns-pxt-query)
- [AI agents and MCP](https://pixeltable.com/use-cases/ai-agents-mcp)
- [Production RAG](https://pixeltable.com/use-cases/production-rag-implementation)
