| <!doctype html> |
| <html lang="en" dir="ltr" class="docs-wrapper docs-doc-page docs-version-current plugin-docs plugin-id-default docs-doc-id-ingestion/partitioning" data-has-hydrated="false"> |
| <head> |
| <meta charset="UTF-8"> |
| <meta name="generator" content="Docusaurus v2.4.3"> |
| <title data-rh="true">Partitioning | Apache® Druid</title><meta data-rh="true" name="viewport" content="width=device-width,initial-scale=1"><meta data-rh="true" name="twitter:card" content="summary_large_image"><meta data-rh="true" property="og:image" content="https://druid.apache.org/img/druid_nav.png"><meta data-rh="true" name="twitter:image" content="https://druid.apache.org/img/druid_nav.png"><meta data-rh="true" property="og:url" content="https://druid.apache.org/docs/31.0.0/ingestion/partitioning"><meta data-rh="true" name="docusaurus_locale" content="en"><meta data-rh="true" name="docsearch:language" content="en"><meta data-rh="true" name="docusaurus_version" content="current"><meta data-rh="true" name="docusaurus_tag" content="docs-default-current"><meta data-rh="true" name="docsearch:version" content="current"><meta data-rh="true" name="docsearch:docusaurus_tag" content="docs-default-current"><meta data-rh="true" property="og:title" content="Partitioning | Apache® Druid"><meta data-rh="true" name="description" content="Describes time chunk and secondary partitioning in Druid. Provides guidance to choose a secondary partition dimension."><meta data-rh="true" property="og:description" content="Describes time chunk and secondary partitioning in Druid. Provides guidance to choose a secondary partition dimension."><link data-rh="true" rel="icon" href="/img/favicon.png"><link data-rh="true" rel="canonical" href="https://druid.apache.org/docs/31.0.0/ingestion/partitioning"><link data-rh="true" rel="alternate" href="https://druid.apache.org/docs/31.0.0/ingestion/partitioning" hreflang="en"><link data-rh="true" rel="alternate" href="https://druid.apache.org/docs/31.0.0/ingestion/partitioning" hreflang="x-default"><link rel="preconnect" href="https://www.google-analytics.com"> |
| <link rel="preconnect" href="https://www.googletagmanager.com"> |
| <script async src="https://www.googletagmanager.com/gtag/js?id=UA-131010415-1"></script> |
| <script>function gtag(){dataLayer.push(arguments)}window.dataLayer=window.dataLayer||[],gtag("js",new Date),gtag("config","UA-131010415-1",{})</script> |
| |
| |
| |
| |
| |
| <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.2/css/all.css"> |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.4/clipboard.min.js"></script><link rel="stylesheet" href="/assets/css/styles.60a7f877.css"> |
| <link rel="preload" href="/assets/js/runtime~main.7d8e1a79.js" as="script"> |
| <link rel="preload" href="/assets/js/main.f9c13e33.js" as="script"> |
| </head> |
| <body class="navigation-with-keyboard"> |
| <script>!function(){function t(t){document.documentElement.setAttribute("data-theme",t)}var e=function(){var t=null;try{t=new URLSearchParams(window.location.search).get("docusaurus-theme")}catch(t){}return t}()||function(){var t=null;try{t=localStorage.getItem("theme")}catch(t){}return t}();t(null!==e?e:"light")}()</script><div id="__docusaurus"> |
| <div role="region" aria-label="Skip to main content"><a class="skipToContent_fXgn" href="#__docusaurus_skipToContent_fallback">Skip to main content</a></div><nav aria-label="Main" class="navbar navbar--fixed-top navbar--dark"><div class="navbar__inner"><div class="navbar__items"><button aria-label="Toggle navigation bar" aria-expanded="false" class="navbar__toggle clean-btn" type="button"><svg width="30" height="30" viewBox="0 0 30 30" aria-hidden="true"><path stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M4 7h22M4 15h22M4 23h22"></path></svg></button><a class="navbar__brand" href="/"><div class="navbar__logo"><img src="/img/druid_nav.png" alt="Apache® Druid" class="themedImage_ToTc themedImage--light_HNdA"><img src="/img/druid_nav.png" alt="Apache® Druid" class="themedImage_ToTc themedImage--dark_i4oU"></div></a></div><div class="navbar__items navbar__items--right"><a class="navbar__item navbar__link" href="/technology">Technology</a><a class="navbar__item navbar__link" href="/use-cases">Use Cases</a><a class="navbar__item navbar__link" href="/druid-powered">Powered By</a><a class="navbar__item navbar__link" href="/docs/31.0.0/design/">Docs</a><a class="navbar__item navbar__link" href="/community/">Community</a><div class="navbar__item dropdown dropdown--hoverable dropdown--right"><a href="#" aria-haspopup="true" aria-expanded="false" role="button" class="navbar__link">Apache®</a><ul class="dropdown__menu"><li><a href="https://www.apache.org/" target="_blank" rel="noopener noreferrer" class="dropdown__link">Foundation<svg width="12" height="12" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li><li><a href="https://apachecon.com/?ref=druid.apache.org" target="_blank" rel="noopener noreferrer" class="dropdown__link">Events<svg width="12" height="12" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li><li><a href="https://www.apache.org/licenses/" target="_blank" rel="noopener noreferrer" class="dropdown__link">License<svg width="12" height="12" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li><li><a href="https://www.apache.org/foundation/thanks.html" target="_blank" rel="noopener noreferrer" class="dropdown__link">Thanks<svg width="12" height="12" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li><li><a href="https://www.apache.org/security/" target="_blank" rel="noopener noreferrer" class="dropdown__link">Security<svg width="12" height="12" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li><li><a href="https://www.apache.org/foundation/sponsorship.html" target="_blank" rel="noopener noreferrer" class="dropdown__link">Sponsorship<svg width="12" height="12" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li></ul></div><a class="navbar__item navbar__link" href="/downloads/">Download</a><div class="searchBox_ZlJk"><div class="navbar__search"><span aria-label="expand searchbar" role="button" class="search-icon" tabindex="0"></span><input type="search" id="search_input_react" placeholder="Loading..." aria-label="Search" class="navbar__search-input search-bar" disabled=""></div></div></div></div><div role="presentation" class="navbar-sidebar__backdrop"></div></nav><div id="__docusaurus_skipToContent_fallback" class="main-wrapper mainWrapper_z2l0 docsWrapper_BCFX"><button aria-label="Scroll back to top" class="clean-btn theme-back-to-top-button backToTopButton_sjWU" type="button"></button><div class="docPage__5DB"><aside class="theme-doc-sidebar-container docSidebarContainer_b6E3"><div class="sidebarViewport_Xe31"><div class="sidebar_njMd"><nav aria-label="Docs sidebar" class="menu thin-scrollbar menu_SIkG"><ul class="theme-doc-sidebar-menu menu__list"><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-1 menu__list-item"><a class="menu__link" href="/docs/31.0.0/design/">Introduction to Apache Druid</a></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist" aria-expanded="false" href="/docs/31.0.0/tutorials/">Getting started</a><button aria-label="Toggle the collapsible sidebar category 'Getting started'" type="button" class="clean-btn menu__caret"></button></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="/docs/31.0.0/design/architecture">Design</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--active" aria-expanded="true" href="/docs/31.0.0/ingestion/">Ingestion</a><button aria-label="Toggle the collapsible sidebar category 'Ingestion'" type="button" class="clean-btn menu__caret"></button></div><ul style="display:block;overflow:visible;height:auto" class="menu__list"><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-2 menu__list-item"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret menu__link--active" aria-expanded="true" tabindex="0" href="/docs/31.0.0/ingestion/data-formats">Ingestion concepts</a></div><ul style="display:block;overflow:visible;height:auto" class="menu__list"><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/31.0.0/ingestion/data-formats">Source input formats</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/31.0.0/ingestion/input-sources">Input sources</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/31.0.0/ingestion/schema-model">Schema model</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/31.0.0/ingestion/rollup">Rollup</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link menu__link--active" aria-current="page" tabindex="0" href="/docs/31.0.0/ingestion/partitioning">Partitioning</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/31.0.0/ingestion/tasks">Task reference</a></li></ul></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-2 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" tabindex="0" href="/docs/31.0.0/multi-stage-query/">SQL-based batch</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-2 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" tabindex="0" href="/docs/31.0.0/ingestion/streaming">Streaming</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-2 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" tabindex="0" href="/docs/31.0.0/ingestion/native-batch">Classic batch</a></div></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/31.0.0/ingestion/ingestion-spec">Ingestion spec reference</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/31.0.0/ingestion/schema-design">Schema design tips</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/31.0.0/ingestion/concurrent-append-replace">Concurrent append and replace</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/31.0.0/ingestion/faq">Troubleshooting FAQ</a></li></ul></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist" aria-expanded="false" href="/docs/31.0.0/data-management/">Data management</a><button aria-label="Toggle the collapsible sidebar category 'Data management'" type="button" class="clean-btn menu__caret"></button></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="/docs/31.0.0/querying/sql">Querying</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist" aria-expanded="false" href="/docs/31.0.0/api-reference/">API reference</a><button aria-label="Toggle the collapsible sidebar category 'API reference'" type="button" class="clean-btn menu__caret"></button></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist" aria-expanded="false" href="/docs/31.0.0/configuration/">Configuration</a><button aria-label="Toggle the collapsible sidebar category 'Configuration'" type="button" class="clean-btn menu__caret"></button></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="/docs/31.0.0/api-reference/automatic-compaction-api">Operations</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist" aria-expanded="false" href="/docs/31.0.0/development/overview">Development</a><button aria-label="Toggle the collapsible sidebar category 'Development'" type="button" class="clean-btn menu__caret"></button></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="/docs/31.0.0/release-info/release-notes">Release info</a></div></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-1 menu__list-item"><a class="menu__link" href="/docs/31.0.0/misc/papers-and-talks">Papers</a></li></ul></nav></div></div></aside><main class="docMainContainer_gTbr"><div class="container padding-top--md padding-bottom--lg"><div class="row"><div class="col docItemCol_VOVn"><div class="docItemContainer_Djhp"><article><nav class="theme-doc-breadcrumbs breadcrumbsContainer_Z_bl" aria-label="Breadcrumbs"><ul class="breadcrumbs" itemscope="" itemtype="https://schema.org/BreadcrumbList"><li class="breadcrumbs__item"><a aria-label="Home page" class="breadcrumbs__link" href="/"><svg viewBox="0 0 24 24" class="breadcrumbHomeIcon_YNFT"><path d="M10 19v-5h4v5c0 .55.45 1 1 1h3c.55 0 1-.45 1-1v-7h1.7c.46 0 .68-.57.33-.87L12.67 3.6c-.38-.34-.96-.34-1.34 0l-8.36 7.53c-.34.3-.13.87.33.87H5v7c0 .55.45 1 1 1h3c.55 0 1-.45 1-1z" fill="currentColor"></path></svg></a></li><li itemscope="" itemprop="itemListElement" itemtype="https://schema.org/ListItem" class="breadcrumbs__item"><a class="breadcrumbs__link" itemprop="item" href="/docs/31.0.0/ingestion/"><span itemprop="name">Ingestion</span></a><meta itemprop="position" content="1"></li><li class="breadcrumbs__item"><span class="breadcrumbs__link">Ingestion concepts</span><meta itemprop="position" content="2"></li><li itemscope="" itemprop="itemListElement" itemtype="https://schema.org/ListItem" class="breadcrumbs__item breadcrumbs__item--active"><span class="breadcrumbs__link" itemprop="name">Partitioning</span><meta itemprop="position" content="3"></li></ul></nav><div class="tocCollapsible_ETCw theme-doc-toc-mobile tocMobile_ITEo"><button type="button" class="clean-btn tocCollapsibleButton_TO0P">On this page</button></div><div class="theme-doc-markdown markdown"><header><h1>Partitioning</h1></header><p>You can use segment partitioning and sorting within your Druid datasources to reduce the size of your data and increase performance.</p><p>One way to partition is to load data into separate datasources. This is a perfectly viable approach that works very well when the number of datasources does not lead to excessive per-datasource overheads.</p><p>This topic describes how to set up partitions within a single datasource. It does not cover how to use multiple datasources. See <a href="/docs/31.0.0/querying/multitenancy">Multitenancy considerations</a> for more details on splitting data into separate datasources and potential operational considerations.</p><h2 class="anchor anchorWithStickyNavbar_LWe7" id="time-chunk-partitioning">Time chunk partitioning<a href="#time-chunk-partitioning" class="hash-link" aria-label="Direct link to Time chunk partitioning" title="Direct link to Time chunk partitioning"></a></h2><p>Druid always partitions datasources by time into <em>time chunks</em>. Each time chunk contains one or more segments. This partitioning happens for all ingestion methods based on the <code>segmentGranularity</code> parameter in your ingestion spec <code>dataSchema</code> object.</p><p>Partitioning by time is important for two reasons:</p><ol><li>Queries that filter by <code>__time</code> (SQL) or <code>intervals</code> (native) are able to use time partitioning to prune the set of segments to consider.</li><li>Certain data management operations, such as overwriting and compacting existing data, acquire exclusive write locks on time partitions.</li><li>Each segment file is wholly contained within a time partition. Too-fine-grained partitioning may cause a large number |
| of small segments, which leads to poor performance.</li></ol><p>The most common choices to balance these considerations are <code>hour</code> and <code>day</code>. For streaming ingestion, <code>hour</code> is especially |
| common, because it allows compaction to follow ingestion with less of a time delay.</p><p>The following table describes how to configure time chunk partitioning.</p><table><thead><tr><th>Method</th><th>Configuration</th></tr></thead><tbody><tr><td><a href="/docs/31.0.0/multi-stage-query/">SQL</a></td><td><a href="/docs/31.0.0/multi-stage-query/concepts#partitioning"><code>PARTITIONED BY</code></a></td></tr><tr><td><a href="/docs/31.0.0/ingestion/kafka-ingestion">Kafka</a> or <a href="/docs/31.0.0/ingestion/kinesis-ingestion">Kinesis</a></td><td><code>segmentGranularity</code> inside the <a href="/docs/31.0.0/ingestion/ingestion-spec#granularityspec"><code>granularitySpec</code></a></td></tr><tr><td><a href="/docs/31.0.0/ingestion/native-batch">Native batch</a> or <a href="/docs/31.0.0/ingestion/hadoop">Hadoop</a></td><td><code>segmentGranularity</code> inside the <a href="/docs/31.0.0/ingestion/ingestion-spec#granularityspec"><code>granularitySpec</code></a></td></tr></tbody></table><h2 class="anchor anchorWithStickyNavbar_LWe7" id="secondary-partitioning">Secondary partitioning<a href="#secondary-partitioning" class="hash-link" aria-label="Direct link to Secondary partitioning" title="Direct link to Secondary partitioning"></a></h2><p>Druid further partitions each time chunk into immutable segments. Secondary partitioning on a particular dimension improves locality. This means that rows with the same value for that dimension are stored together, decreasing access time.</p><p>To achieve the best performance and smallest overall footprint, partition your data on a "natural" dimension that |
| you often use as a filter, or that achieves some alignment within your data. Such partitioning can improve compression |
| and query performance by significant multiples.</p><p>The following table describes how to configure secondary partitioning.</p><table><thead><tr><th>Method</th><th>Configuration</th></tr></thead><tbody><tr><td><a href="/docs/31.0.0/multi-stage-query/">SQL</a></td><td><a href="/docs/31.0.0/multi-stage-query/concepts#clustering"><code>CLUSTERED BY</code></a></td></tr><tr><td><a href="/docs/31.0.0/ingestion/kafka-ingestion">Kafka</a> or <a href="/docs/31.0.0/ingestion/kinesis-ingestion">Kinesis</a></td><td>Upstream partitioning defines how Druid partitions the datasource. You can also alter clustering using <a href="/docs/31.0.0/multi-stage-query/concepts#replace"><code>REPLACE</code></a> (with <code>CLUSTERED BY</code>) or <a href="/docs/31.0.0/data-management/compaction">compaction</a> after initial ingestion.</td></tr><tr><td><a href="/docs/31.0.0/ingestion/native-batch">Native batch</a> or <a href="/docs/31.0.0/ingestion/hadoop">Hadoop</a></td><td><a href="/docs/31.0.0/ingestion/native-batch#partitionsspec"><code>partitionsSpec</code></a> inside the <code>tuningConfig</code></td></tr></tbody></table><h2 class="anchor anchorWithStickyNavbar_LWe7" id="sorting">Sorting<a href="#sorting" class="hash-link" aria-label="Direct link to Sorting" title="Direct link to Sorting"></a></h2><p>Each segment is internally sorted to promote compression and locality.</p><p>Partitioning and sorting work well together. If you do have a "natural" partitioning dimension, consider placing it |
| first in your sort order as well. This way, Druid sorts rows within each segment by that column. This sorting configuration |
| frequently improves compression and performance more than using partitioning alone.</p><p>The following table describes how to configure sorting.</p><table><thead><tr><th>Method</th><th>Configuration</th></tr></thead><tbody><tr><td><a href="/docs/31.0.0/multi-stage-query/">SQL</a></td><td>Uses order of fields in <a href="/docs/31.0.0/multi-stage-query/concepts#clustering"><code>CLUSTERED BY</code></a> or <a href="/docs/31.0.0/multi-stage-query/reference#context"><code>segmentSortOrder</code></a> in the query context</td></tr><tr><td><a href="/docs/31.0.0/ingestion/kafka-ingestion">Kafka</a> or <a href="/docs/31.0.0/ingestion/kinesis-ingestion">Kinesis</a></td><td>Uses order of fields in <a href="/docs/31.0.0/ingestion/ingestion-spec#granularityspec"><code>dimensionsSpec</code></a></td></tr><tr><td><a href="/docs/31.0.0/ingestion/native-batch">Native batch</a> or <a href="/docs/31.0.0/ingestion/hadoop">Hadoop</a></td><td>Uses order of fields in <a href="/docs/31.0.0/ingestion/ingestion-spec#granularityspec"><code>dimensionsSpec</code></a></td></tr></tbody></table><div class="theme-admonition theme-admonition-info alert alert--info admonition_LlT9"><div class="admonitionHeading_tbUL"><span class="admonitionIcon_kALy"><svg viewBox="0 0 14 16"><path fill-rule="evenodd" d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg></span>info</div><div class="admonitionContent_S0QG"><p>Druid implicitly sorts rows within a segment by <code>__time</code> first before any <code>dimensions</code> or <code>CLUSTERED BY</code> fields, unless |
| you set <code>forceSegmentSortByTime</code> to <code>false</code> in your |
| <a href="/docs/31.0.0/multi-stage-query/reference#context-parameters">query context</a> (for SQL) or in your |
| <a href="/docs/31.0.0/ingestion/ingestion-spec#dimensionsspec"><code>dimensionsSpec</code></a> (for other ingestion forms).</p><p>Setting <code>forceSegmentSortByTime</code> to <code>false</code> is an experimental feature. Segments created with sort orders that |
| do not start with <code>__time</code> can only be read by Druid 31 or later. Additionally, at this time, certain queries are not |
| supported on such segments, including:</p><ul><li>Native queries with <code>granularity</code> other than <code>all</code>.</li><li>Native <code>scan</code> query with ascending or descending time order.</li><li>SQL queries that plan into an unsupported native query.</li></ul></div></div><h2 class="anchor anchorWithStickyNavbar_LWe7" id="learn-more">Learn more<a href="#learn-more" class="hash-link" aria-label="Direct link to Learn more" title="Direct link to Learn more"></a></h2><p>See the following topics for more information:</p><ul><li><a href="/docs/31.0.0/ingestion/native-batch#partitionsspec"><code>partitionsSpec</code></a> for more detail on partitioning with Native Batch ingestion.</li><li><a href="/docs/31.0.0/data-management/update#reindex">Reindexing</a> and <a href="/docs/31.0.0/data-management/compaction">Compaction</a> for information on how to repartition existing data in Druid.</li></ul></div></article><nav class="pagination-nav docusaurus-mt-lg" aria-label="Docs pages"><a class="pagination-nav__link pagination-nav__link--prev" href="/docs/31.0.0/ingestion/rollup"><div class="pagination-nav__sublabel">Previous</div><div class="pagination-nav__label">Rollup</div></a><a class="pagination-nav__link pagination-nav__link--next" href="/docs/31.0.0/ingestion/tasks"><div class="pagination-nav__sublabel">Next</div><div class="pagination-nav__label">Task reference</div></a></nav></div></div><div class="col col--3"><div class="tableOfContents_bqdL thin-scrollbar theme-doc-toc-desktop"><ul class="table-of-contents table-of-contents__left-border"><li><a href="#time-chunk-partitioning" class="table-of-contents__link toc-highlight">Time chunk partitioning</a></li><li><a href="#secondary-partitioning" class="table-of-contents__link toc-highlight">Secondary partitioning</a></li><li><a href="#sorting" class="table-of-contents__link toc-highlight">Sorting</a></li><li><a href="#learn-more" class="table-of-contents__link toc-highlight">Learn more</a></li></ul></div></div></div></div></main></div></div><footer class="footer"><div class="container container-fluid"><div class="footer__bottom text--center"><div class="margin-bottom--sm"><img src="/img/favicon.png" class="themedImage_ToTc themedImage--light_HNdA footer__logo"><img src="/img/favicon.png" class="themedImage_ToTc themedImage--dark_i4oU footer__logo"></div><div class="footer__copyright">Copyright © 2023 Apache Software Foundation. Except where otherwise noted, licensed under CC BY-SA 4.0. Apache Druid, Druid, and the Druid logo are either registered trademarks or trademarks of The Apache Software Foundation in the United States and other countries.</div></div></div></footer></div> |
| <script src="/assets/js/runtime~main.7d8e1a79.js"></script> |
| <script src="/assets/js/main.f9c13e33.js"></script> |
| </body> |
| </html> |