druid/docs/content/Querying.md

59 lines
2.1 KiB
Markdown
Raw Normal View History

---
2013-09-26 19:22:28 -04:00
layout: doc_page
---
2014-08-01 18:27:38 -04:00
2013-09-13 18:20:39 -04:00
Querying
========
2015-03-26 13:44:11 -04:00
Queries are made using an HTTP REST style request to queryable nodes ([Broker](Broker.html),
[Historical](Historical.html), or [Realtime](Realtime.html)). The
2014-08-01 18:27:38 -04:00
query is expressed in JSON and each of these node types expose the same
2015-03-26 13:44:11 -04:00
REST query interface. For normal Druid operations, queries should be issued to the broker nodes.
2015-03-26 13:44:11 -04:00
Although Druid's native query language is JSON over HTTP, many members of the community have contributed different [client libraries](./Libraries.html) in other languages to query Druid.
2015-03-26 13:44:11 -04:00
Available Queries
-----------------
2013-09-13 18:20:39 -04:00
2015-03-26 13:44:11 -04:00
Druid has numerous query types for various use cases. Queries are composed of various JSON properties and Druid has different types of queries for different use cases. The documentation for the various query types describe all the JSON properties that can be set.
2013-09-13 18:20:39 -04:00
2015-03-26 13:44:11 -04:00
### Aggregation Queries
2013-09-13 18:20:39 -04:00
2015-03-26 13:44:11 -04:00
* [Timeseries](./TimeseriesQuery.html)
* [TopN](./TopNQuery.html)
* [GroupBy](./GroupByQuery.html)
2015-03-26 13:44:11 -04:00
### Metadata Queries
2015-03-26 13:44:11 -04:00
* [Time Boundary](./TimeBoundaryQuery.html)
* [Segment Metadata](./SegmentMetadataQuery.html)
* [Datasource Metadata](./DatasourceMetadataQuery.html)
2015-03-26 13:44:11 -04:00
### Search Queries
2013-09-13 18:20:39 -04:00
2015-03-26 13:44:11 -04:00
* [Search](./SearchQuery.html)
2015-03-26 13:44:11 -04:00
Which Query Should I Use?
-------------------------
2015-03-26 13:44:11 -04:00
Where possible, we recommend using [Timeseries]() and [TopN]() queries instead of [GroupBy](). GroupBy is the most flexible Druid query, but also has the poorest performance.
Timeseries are significantly faster than groupBy queries for aggregations that don't require grouping over dimensions. For grouping and sorting over a single dimension,
topN queries are much more optimized than groupBys.
Query Cancellation
------------------
2013-09-13 18:20:39 -04:00
2015-03-26 13:44:11 -04:00
Queries can be cancelled explicitly using their unique identifier. If the
2014-08-01 18:27:38 -04:00
query identifier is set at the time of query, or is otherwise known, the following
endpoint can be used on the broker or router to cancel the query.
```sh
DELETE /druid/v2/{queryId}
```
For example, if the query ID is `abc123`, the query can be cancelled as follows:
```sh
curl -X DELETE "http://host:port/druid/v2/abc123"
```