Blog
Ad hoc queries: definition, benefits, and best practices
A PM pings you for retention numbers by region, and by Thursday two more teams want variations on the same logic. That's where things start to drift.

A PM pings you on Slack asking for last quarter's retention numbers by region. You're halfway through something else, but the quarterly business review (QBR) is tomorrow, so you pull up your SQL editor, write the query, share the results, and get back to what you were doing. Two days later, marketing wants the same logic applied to campaigns. Then finance asks for a version filtered by account tier.
That's the reality of ad hoc queries. They're one-off, user-defined data requests written to answer specific questions outside the scope of existing dashboards and reports. The term comes from Latin, meaning "for this purpose," and the name fits: every ad hoc query exists because a question arrived that nothing pre-built could answer.
You probably already knew that. What's worth examining is why ad hoc queries remain the default way most data work actually gets done, what they really cost, and how to run them without creating a mess.
Why ad hoc queries still run the show
In practice, dashboards tend to answer anticipated questions, while ad hoc queries are what teams reach for when new ones come up. These are fundamentally different categories of work, and the unanticipated questions tend to be the important ones.
Ad hoc analysis often supports one-time decisions: strategic pivots, market entry choices, pricing changes. The decisions that justify a dashboard are usually recurring and operational. That's part of what makes ad hoc work high-stakes.
Here's a non-exhaustive list of what ad hoc queries routinely handle that dashboards can't:
- Investigating anomalies. A dashboard shows a metric dropped 15%. The dashboard can't tell you why. Crossing from the visualization into an analytical tool capable of digging into the cause is where ad hoc queries pick up.
- Preparing for meetings. One-off number pulls for board decks and QBRs need custom slicing no standing dashboard was designed for.
- Validating data before building. Before any pipeline or dashboard gets built, analysts use ad hoc queries to check table structure, nulls, join keys, and metric logic.
- Resolving metric disputes. When two dashboards show different revenue numbers, only a raw SQL query against underlying tables can arbitrate.
Those are the kinds of questions that usually stay outside a dashboard's fixed frame.
The exploratory data analysis workflow follows a consistent pattern: a question arrives (via Slack, a dashboard anomaly, or the analyst's own investigation), the analyst writes SQL iteratively against the data warehouse, and results get shared informally through a CSV, screenshot, or Slack message. Ad hoc queries often precede productionized work. They're how analysts determine whether a question is worth building a dashboard for at all.
The real cost sits around the query
Writing SQL is the easy part. The expensive parts are everything around it.
The request queue
Without visibility into queue depth, ongoing projects, or data complexity, stakeholders set deadlines based on what feels reasonable. Those arbitrary timelines continuously destabilize sprint planning. Teams that implement more formal request queues often find that a typical request can still take long enough to be unsuitable for anything urgent. And when queues run deep, teams can end up delivering work after the moment when it would have been most useful.
Data quality is often the most visible symptom of immature analytics workflows that can't find and fix issues early. That often follows from reactive, ungoverned ad hoc culture.
Metric inconsistency
This is the most organizationally visible cost because it surfaces in the open, in meetings where leaders discover they're working from different numbers. "Revenue" defined one way in Finance, another way in Sales, a third way in Product. The technical mechanism is often the same: SQL logic lives in individual notebooks, Slack threads, or analyst-owned files rather than in a versioned, governed semantic layer. Every copy is a potential divergence point.
Knowledge that disappears
A common structural failure in analytics work is that discoveries in BI tools are ephemeral, ad hoc analysis is scattered across scratch work, and the conversations where decisions get made disappear into Slack. Three simultaneous failure modes show up here: dashboard impermanence, notebook scatter, and conversation loss. Teams re-derive the same answers repeatedly as analysts turn over and institutional context resets. The costliest outcome of ad hoc culture is the loss of good analysis.
Why "just build a dashboard" isn't the answer
Many analysts have worked hard to create a dashboard and then watched it go largely unused by the stakeholders it was built for. The dashboard graveyard is a familiar name for that pattern.
The organizational pattern is familiar: when teams face pressure to demonstrate quantifiable business impact, dashboards get spun up quickly and accumulate into a graveyard of low-value artifacts with real maintenance and compute costs.
The cycle is predictable. A stakeholder asks an ad hoc question. Someone files a ticket to build a dashboard. The dashboard ships weeks later. By then, OKRs have shifted and the question has evolved. The stakeholder asks a new ad hoc question. Repeat.
This pattern is common. Dashboards are built around a fixed framing of the questions they are meant to answer. But business concepts are fluid: new OKRs get spun up every quarter, projects take off or wind down. Dashboards built for last quarter's framing are misaligned with this quarter's questions before they're fully used.
That tension between dashboard investment and actual analytical work keeps growing. In Hex's State of Data Teams 2026 report, 31% of data leaders cited trust as their top concern around AI adoption, nearly twice any other response. The gap between the tools teams have and the answers stakeholders need is widening, not closing.
As organizations grow, data teams often see request volume increase with company headcount. Building a dashboard for every ad hoc request creates a multi-step artifact that needs ongoing maintenance, rarely resolves the underlying question completely, and generates future requests of its own.
Governed context makes ad hoc queries safe by default
The usual framing presents a binary: ad hoc queries move quickly with less governance, while dashboards offer more governance and take longer to build. Embedding governance into the ad hoc workflow itself is the practical answer.
Without governed access to trusted data assets, analysts who need answers quickly turn to untrustworthy sources. That leads to broken dashboards, misinformed decisions, and more ad hoc engineering requests. Ungoverned self-service creates more work.
Governance doesn't need a full semantic layer before anyone can start querying. It works as a spectrum.
Endorse tables and add metadata. The lightest intervention is marking which tables are production-grade and safe for querying, and which are raw or intermediate. This costs almost nothing and immediately reduces the risk of analysts joining the wrong tables.
Add workspace rules. Document company-specific terminology, definitions, and best practices. When everyone knows that "active customer" means "anyone with a transaction in the last 90 days," that can resolve many metric disputes.
Define metrics in code. The most direct technical governance mechanism is encoding aggregations in Semantic Modeling rather than leaving them to each query author. When the finance team and marketing team both query last quarter's revenue, they should get consistent answers because both pull from the same governed definition.
Monitor and close gaps. Governance is only useful if people follow it. Observability tools that surface where context is missing or where queries are returning inconsistent results close the feedback loop.
In Hex, anyone can explore data using natural language, with or without code, on trusted context in one unified workspace. Natural-language analysis generates SQL under the hood. This spectrum is built into the platform through Context Studio. Teams can start with lightweight data endorsements and metadata, then layer in deeper semantic models over time. These governance improvements can support a range of workflows across the platform.
Access policies applied at the semantic layer work across tools. They govern ad hoc queries, dashboards, and embedded analytics uniformly without needing separate policy enforcement in each tool.
What changes when stakeholders self-serve
Self-service analytics without governance creates a different class of support work. In practice, teams often move from "pull this data for me" requests toward questions about why self-serve results don't match other reported numbers. This pattern has played out at enough organizations that it's worth naming explicitly.
When self-serve does work, the shift can be significant. Data teams spend less time responding to ad hoc requests and more time on strategic initiatives. Analysts explore and investigate data independently, while engineers focus on building and maintaining proper infrastructure rather than responding to tickets.
This played out at ClickUp's churn model, where the data science team built a self-service application in Hex with guardrails. The result: the app helped teams identify strategies for reducing churn, delivering savings of more than $1M. Marketing optimized campaigns, lifecycle teams created targeted outreach, and customer success focused on the highest-revenue accounts.
When stakeholders have governed self-serve access through tools like Threads, they can ask questions in plain language and get answers grounded in the organization's actual data, metrics, and business rules. No SQL ticket, and a much shorter path to an answer. That can give the data team hours back, and the questions that do reach them are more likely to be the genuinely complex ones worth their time.
Best practices for ad hoc analysis that scales
Scaling ad hoc work is a systems problem. These practices convert ephemeral analysis into durable, reusable artifacts.
Define business logic once, not per request
When a query joins three or more tables or encodes a business definition like "active customer," that logic belongs in a shared model or view. Without this, transformations scatter across different platforms and teams reimplement the same joins and filters for each new project. Ask whether a colleague would need to re-derive that logic independently to answer a related question. If yes, centralize it.
Parameterize from the start
The difference between a query that works for one run and one any analyst can adapt in seconds is parameterization. Declare named variables for date ranges, entity identifiers, and thresholds at the top of the query rather than burying literals in WHERE clauses.
-- Parameters: adjust these to change the analysis window-- start_date: '2024-01-01'-- end_date: '2024-03-31'-- segment: 'enterprise'This makes the query self-documenting and immediately reusable.
Document as you go, not after
Most pipelines and queries go undocumented, which makes it harder for anyone else to understand how data is derived. A minimum viable header block covering what question this answers, the date range, assumptions, and who requested it makes a query findable and reusable in under two minutes. That's the threshold between a personal query and a shareable artifact.
Build a query library from recurring patterns
After enough iterations, similar query types keep recurring: usage analytics, revenue breakdowns, cohort comparisons. The second time someone asks that question, the answer should be a lookup, not a rewrite. A shared query library organized by business domain, even just a named folder in a Git repo or wiki, captures these patterns.
Know when ad hoc work has earned a permanent home
Some ad hoc queries should stay one-off, while others should move into a dashboard. Use these signals to decide.
Before promoting anything, share the result with the stakeholder and ask whether this is the right question and whether they'd look at it weekly. Many requests are resolved at this stage, which is the correct outcome.
Validate with tight feedback loops
In collaborative notebooks, ad hoc work and data collaboration happen in the same place: SQL, Python, and no-code exploration in one canvas with real-time multiplayer editing, comments, and version history. An analysis can start as a quick ad hoc answer and, once validated, become a published data app without switching tools or rebuilding. Nothing disappears into a screenshot or a slide deck.
From one-off answers to shared knowledge
Ad hoc queries are often the right tool for high-stakes, one-off questions. The problem is what happens around them: the request queue that delays answers, the metric definitions that drift, the good analysis that disappears into Slack.
Fixing this doesn't mean eliminating ad hoc work. It means giving it structure: governed context so every query runs against trusted definitions, collaboration so analysis is visible and reusable, and a clear path from exploration to production when a question earns it.
Hex brings these pieces together in one unified workspace, so data teams can move from question to trusted answer to shared artifact without the tool sprawl and lost context that make ad hoc work expensive. Sign up for free or request a demo to see how different the workflow feels.
Frequently Asked Questions
How do you prevent ad hoc queries from producing conflicting numbers across teams?
A common root cause is that metric definitions live in individual queries rather than in a shared, versioned location. The fix is defining your most important metrics (revenue, active customers, churn) once in Semantic Modeling or a governed view, then having every ad hoc query pull from those definitions instead of re-deriving them. You don't need to model everything on day one. Start with the five or ten metrics that show up in leadership meetings, and expand from there. The goal is that when two people query the same metric from different tools, they get the same answer every time.
When should a data team say no to an ad hoc request?
Saying no outright tends to push stakeholders toward ungoverned workarounds, which is worse. A better approach is qualifying the request before committing resources: what decision does this support, when does it need to happen, and has this question been asked before? If it's a recurring question, the right response is building a reusable artifact rather than answering one-off. If it's genuinely one-time and low-stakes, a quick answer with a documented query is often the most efficient path. The distinction between "I need this number" and "I need to understand this pattern" also matters, since the second usually needs a conversation rather than a data pull.
How do you get stakeholders to actually use self-serve analytics instead of filing tickets?
Adoption tends to fail when teams announce self-serve access and expect behavior to change overnight. What works is starting with a focused use case and a small group of motivated users, then expanding based on what actually gets used. Stakeholders adopt self-serve tools when the experience is faster than filing a ticket and when they trust the numbers they're getting back. That trust comes from governed context: endorsed tables, defined metrics, and clear signals about which data is production-grade. If a business user asks a question and gets an answer that contradicts the dashboard, they'll stop trusting the tool immediately, so self-serve adoption depends on accuracy.