blob: 7523e6163d08e9891ef7bb53389031b2eb3cc87b [file] [log] [blame]
<!doctype html>
<html lang="en" dir="ltr" class="docs-wrapper docs-doc-page docs-version-current plugin-docs plugin-id-default docs-doc-id-data-management/automatic-compaction" data-has-hydrated="false">
<head>
<meta charset="UTF-8">
<meta name="generator" content="Docusaurus v2.4.3">
<title data-rh="true">Automatic compaction | 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/latest/data-management/automatic-compaction"><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="Automatic compaction | Apache® Druid"><meta data-rh="true" name="description" content="&lt;!--"><meta data-rh="true" property="og:description" content="&lt;!--"><link data-rh="true" rel="icon" href="/img/favicon.png"><link data-rh="true" rel="canonical" href="https://druid.apache.org/docs/latest/data-management/automatic-compaction"><link data-rh="true" rel="alternate" href="https://druid.apache.org/docs/latest/data-management/automatic-compaction" hreflang="en"><link data-rh="true" rel="alternate" href="https://druid.apache.org/docs/latest/data-management/automatic-compaction" 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.b5a26022.js" as="script">
<link rel="preload" href="/assets/js/main.9dc00f46.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/latest/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/latest/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/latest/tutorials/">Getting started</a><button aria-label="Toggle the collapsible sidebar category &#x27;Getting started&#x27;" 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/latest/design/architecture">Design</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/latest/ingestion/">Ingestion</a><button aria-label="Toggle the collapsible sidebar category &#x27;Ingestion&#x27;" 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"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--active" aria-expanded="true" href="/docs/latest/data-management/">Data management</a><button aria-label="Toggle the collapsible sidebar category &#x27;Data management&#x27;" 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-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/latest/data-management/update">Data updates</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/latest/data-management/delete">Data deletion</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/latest/data-management/schema-changes">Schema changes</a></li><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--active" aria-expanded="true" tabindex="0" href="/docs/latest/data-management/compaction">Compaction</a><button aria-label="Toggle the collapsible sidebar category &#x27;Compaction&#x27;" 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-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/latest/data-management/automatic-compaction">Automatic compaction</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/latest/data-management/manual-compaction">Manual compaction</a></li></ul></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 menu__link--sublist-caret" aria-expanded="false" href="/docs/latest/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/latest/api-reference/">API reference</a><button aria-label="Toggle the collapsible sidebar category &#x27;API reference&#x27;" 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/latest/configuration/">Configuration</a><button aria-label="Toggle the collapsible sidebar category &#x27;Configuration&#x27;" 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/latest/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/latest/development/overview">Development</a><button aria-label="Toggle the collapsible sidebar category &#x27;Development&#x27;" 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/latest/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/latest/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/latest/data-management/"><span itemprop="name">Data management</span></a><meta itemprop="position" content="1"></li><li itemscope="" itemprop="itemListElement" itemtype="https://schema.org/ListItem" class="breadcrumbs__item"><a class="breadcrumbs__link" itemprop="item" href="/docs/latest/data-management/compaction"><span itemprop="name">Compaction</span></a><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">Automatic compaction</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>Automatic compaction</h1></header><p>In Apache Druid, compaction is a special type of ingestion task that reads data from a Druid datasource and writes it back into the same datasource. A common use case for this is to <a href="/docs/latest/operations/segment-optimization">optimally size segments</a> after ingestion to improve query performance. Automatic compaction, or auto-compaction, refers to the system for automatic execution of compaction tasks issued by Druid itself. In addition to auto-compaction, you can perform <a href="/docs/latest/data-management/manual-compaction">manual compaction</a> using the Overlord APIs.</p><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> Auto-compaction skips datasources that have a segment granularity of <code>ALL</code>.</p></div></div><p>As a best practice, you should set up auto-compaction for all Druid datasources. You can run compaction tasks manually for cases where you want to allocate more system resources. For example, you may choose to run multiple compaction tasks in parallel to compact an existing datasource for the first time. See <a href="/docs/latest/data-management/compaction">Compaction</a> for additional details and use cases.</p><p>This topic guides you through setting up automatic compaction for your Druid cluster. See the <a href="#examples">examples</a> for common use cases for automatic compaction.</p><h2 class="anchor anchorWithStickyNavbar_LWe7" id="auto-compaction-syntax">Auto-compaction syntax<a href="#auto-compaction-syntax" class="hash-link" aria-label="Direct link to Auto-compaction syntax" title="Direct link to Auto-compaction syntax"></a></h2><p>You can configure automatic compaction dynamically without restarting Druid.
The automatic compaction system uses the following syntax:</p><div class="language-json codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#bfc7d5;--prism-background-color:#292d3e"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-json codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#bfc7d5"><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token property">&quot;dataSource&quot;</span><span class="token operator" style="color:rgb(137, 221, 255)">:</span><span class="token plain"> &lt;task_datasource&gt;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token property">&quot;ioConfig&quot;</span><span class="token operator" style="color:rgb(137, 221, 255)">:</span><span class="token plain"> &lt;IO config&gt;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token property">&quot;dimensionsSpec&quot;</span><span class="token operator" style="color:rgb(137, 221, 255)">:</span><span class="token plain"> &lt;custom dimensionsSpec&gt;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token property">&quot;transformSpec&quot;</span><span class="token operator" style="color:rgb(137, 221, 255)">:</span><span class="token plain"> &lt;custom transformSpec&gt;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token property">&quot;metricsSpec&quot;</span><span class="token operator" style="color:rgb(137, 221, 255)">:</span><span class="token plain"> &lt;custom metricsSpec&gt;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token property">&quot;tuningConfig&quot;</span><span class="token operator" style="color:rgb(137, 221, 255)">:</span><span class="token plain"> &lt;parallel indexing task tuningConfig&gt;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token property">&quot;granularitySpec&quot;</span><span class="token operator" style="color:rgb(137, 221, 255)">:</span><span class="token plain"> &lt;compaction task granularitySpec&gt;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token property">&quot;skipOffsetFromLatest&quot;</span><span class="token operator" style="color:rgb(137, 221, 255)">:</span><span class="token plain"> &lt;time period to avoid compaction&gt;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token property">&quot;taskPriority&quot;</span><span class="token operator" style="color:rgb(137, 221, 255)">:</span><span class="token plain"> &lt;compaction task priority&gt;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token property">&quot;taskContext&quot;</span><span class="token operator" style="color:rgb(137, 221, 255)">:</span><span class="token plain"> &lt;task context&gt;</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"></span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><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>Experimental</div><div class="admonitionContent_S0QG"><p>The MSQ task engine is available as a compaction engine when you run automatic compaction as a compaction supervisor. For more information, see <a href="#auto-compaction-using-compaction-supervisors">Auto-compaction using compaction supervisors</a>.</p></div></div><p>For automatic compaction using Coordinator duties, you submit the spec to the <a href="#manage-auto-compaction-using-the-web-console">Compaction config UI</a> or the <a href="#manage-auto-compaction-using-coordinator-apis">Compaction configuration API</a>.</p><p>Most fields in the auto-compaction configuration correlate to a typical <a href="/docs/latest/ingestion/ingestion-spec">Druid ingestion spec</a>.
The following properties only apply to auto-compaction:</p><ul><li><code>skipOffsetFromLatest</code></li><li><code>taskPriority</code></li><li><code>taskContext</code></li></ul><p>Since the automatic compaction system provides a management layer on top of manual compaction tasks,
the auto-compaction configuration does not include task-specific properties found in a typical Druid ingestion spec.
The following properties are automatically set by the Coordinator:</p><ul><li><code>type</code>: Set to <code>compact</code>.</li><li><code>id</code>: Generated using the task type, datasource name, interval, and timestamp. The task ID is prefixed with <code>coordinator-issued</code>.</li><li><code>context</code>: Set according to the user-provided <code>taskContext</code>.</li></ul><p>Compaction tasks typically fetch all <a href="/docs/latest/data-management/manual-compaction#compaction-io-configuration">relevant segments</a> prior to launching any subtasks,
<em>unless</em> the following properties are all set to non-null values. It is strongly recommended to set them to non-null values to
maximize performance and minimize disk usage of the <code>compact</code> tasks launched by auto-compaction:</p><ul><li><a href="/docs/latest/data-management/manual-compaction#compaction-granularity-spec"><code>granularitySpec</code></a>, with non-null values for each of <code>segmentGranularity</code>, <code>queryGranularity</code>, and <code>rollup</code></li><li><a href="/docs/latest/data-management/manual-compaction#compaction-dimensions-spec"><code>dimensionsSpec</code></a></li><li><code>metricsSpec</code></li></ul><p>For more details on each of the specs in an auto-compaction configuration, see <a href="/docs/latest/configuration/#automatic-compaction-dynamic-configuration">Automatic compaction dynamic configuration</a>.</p><h2 class="anchor anchorWithStickyNavbar_LWe7" id="auto-compaction-using-coordinator-duties">Auto-compaction using Coordinator duties<a href="#auto-compaction-using-coordinator-duties" class="hash-link" aria-label="Direct link to Auto-compaction using Coordinator duties" title="Direct link to Auto-compaction using Coordinator duties"></a></h2><p>You can control how often the Coordinator checks to see if auto-compaction is needed. The Coordinator <a href="/docs/latest/configuration/#coordinator-operation">indexing period</a>, <code>druid.coordinator.period.indexingPeriod</code>, controls the frequency of compaction tasks.
The default indexing period is 30 minutes, meaning that the Coordinator first checks for segments to compact at most 30 minutes from when auto-compaction is enabled.
This time period also affects other Coordinator duties such as cleanup of unused segments and stale pending segments.
To configure the auto-compaction time period without interfering with <code>indexingPeriod</code>, see <a href="#change-compaction-frequency">Set frequency of compaction runs</a>.</p><p>At every invocation of auto-compaction, the Coordinator initiates a <a href="/docs/latest/design/coordinator#segment-search-policy-in-automatic-compaction">segment search</a> to determine eligible segments to compact.
When there are eligible segments to compact, the Coordinator issues compaction tasks based on available worker capacity.
If a compaction task takes longer than the indexing period, the Coordinator waits for it to finish before resuming the period for segment search.</p><p>No additional configuration is needed to run automatic compaction tasks using the Coordinator and native engine. This is the default behavior for Druid.
You can configure it for a datasource through the web console or programmatically via an API.
This process differs for manual compaction tasks, which can be submitted from the <a href="/docs/latest/operations/web-console">Tasks view of the web console</a> or the <a href="/docs/latest/api-reference/tasks-api">Tasks API</a>.</p><h3 class="anchor anchorWithStickyNavbar_LWe7" id="manage-auto-compaction-using-the-web-console">Manage auto-compaction using the web console<a href="#manage-auto-compaction-using-the-web-console" class="hash-link" aria-label="Direct link to Manage auto-compaction using the web console" title="Direct link to Manage auto-compaction using the web console"></a></h3><p>Use the web console to enable automatic compaction for a datasource as follows:</p><ol><li>Click <strong>Datasources</strong> in the top-level navigation.</li><li>In the <strong>Compaction</strong> column, click the edit icon for the datasource to compact.</li><li>In the <strong>Compaction config</strong> dialog, configure the auto-compaction settings. The dialog offers a form view as well as a JSON view. Editing the form updates the JSON specification, and editing the JSON updates the form field, if present. Form fields not present in the JSON indicate default values. You may add additional properties to the JSON for auto-compaction settings not displayed in the form. See <a href="#auto-compaction-syntax">Configure automatic compaction</a> for supported settings for auto-compaction.</li><li>Click <strong>Submit</strong>.</li><li>Refresh the <strong>Datasources</strong> view. The <strong>Compaction</strong> column for the datasource changes from “Not enabled” to “Awaiting first run.”</li></ol><p>The following screenshot shows the compaction config dialog for a datasource with auto-compaction enabled.
<img loading="lazy" alt="Compaction config in web console" src="/assets/images/compaction-config-2d5e391fe681a9c978060c383357b531.png" width="1250" height="640" class="img_ev3q"></p><p>To disable auto-compaction for a datasource, click <strong>Delete</strong> from the <strong>Compaction config</strong> dialog. Druid does not retain your auto-compaction configuration.</p><h3 class="anchor anchorWithStickyNavbar_LWe7" id="manage-auto-compaction-using-coordinator-apis">Manage auto-compaction using Coordinator APIs<a href="#manage-auto-compaction-using-coordinator-apis" class="hash-link" aria-label="Direct link to Manage auto-compaction using Coordinator APIs" title="Direct link to Manage auto-compaction using Coordinator APIs"></a></h3><p>Use the <a href="/docs/latest/api-reference/automatic-compaction-api#manage-automatic-compaction">Automatic compaction API</a> to configure automatic compaction.
To enable auto-compaction for a datasource, create a JSON object with the desired auto-compaction settings.
See <a href="#auto-compaction-syntax">Configure automatic compaction</a> for the syntax of an auto-compaction spec.
Send the JSON object as a payload in a <a href="/docs/latest/api-reference/automatic-compaction-api#create-or-update-automatic-compaction-configuration"><code>POST</code> request</a> to <code>/druid/coordinator/v1/config/compaction</code>.
The following example configures auto-compaction for the <code>wikipedia</code> datasource:</p><div class="language-sh codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#bfc7d5;--prism-background-color:#292d3e"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-sh codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#bfc7d5"><span class="token plain">curl --location --request POST &#x27;http://localhost:8081/druid/coordinator/v1/config/compaction&#x27; \</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain">--header &#x27;Content-Type: application/json&#x27; \</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain">--data-raw &#x27;{</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> &quot;dataSource&quot;: &quot;wikipedia&quot;,</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> &quot;granularitySpec&quot;: {</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> &quot;segmentGranularity&quot;: &quot;DAY&quot;</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> }</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain">}&#x27;</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><p>To disable auto-compaction for a datasource, send a <a href="/docs/latest/api-reference/automatic-compaction-api#remove-automatic-compaction-configuration"><code>DELETE</code> request</a> to <code>/druid/coordinator/v1/config/compaction/{dataSource}</code>. Replace <code>{dataSource}</code> with the name of the datasource for which to disable auto-compaction. For example:</p><div class="language-sh codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#bfc7d5;--prism-background-color:#292d3e"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-sh codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#bfc7d5"><span class="token plain">curl --location --request DELETE &#x27;http://localhost:8081/druid/coordinator/v1/config/compaction/wikipedia&#x27;</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><h3 class="anchor anchorWithStickyNavbar_LWe7" id="change-compaction-frequency">Change compaction frequency<a href="#change-compaction-frequency" class="hash-link" aria-label="Direct link to Change compaction frequency" title="Direct link to Change compaction frequency"></a></h3><p>If you want the Coordinator to check for compaction more frequently than its indexing period, create a separate group to handle compaction duties.
Set the time period of the duty group in the <code>coordinator/runtime.properties</code> file.
The following example shows how to create a duty group named <code>compaction</code> and set the auto-compaction period to 1 minute:</p><div class="codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#bfc7d5;--prism-background-color:#292d3e"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-text codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#bfc7d5"><span class="token plain">druid.coordinator.dutyGroups=[&quot;compaction&quot;]</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain">druid.coordinator.compaction.duties=[&quot;compactSegments&quot;]</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain">druid.coordinator.compaction.period=PT60S</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><h3 class="anchor anchorWithStickyNavbar_LWe7" id="view-coordinator-duty-auto-compaction-stats">View Coordinator duty auto-compaction stats<a href="#view-coordinator-duty-auto-compaction-stats" class="hash-link" aria-label="Direct link to View Coordinator duty auto-compaction stats" title="Direct link to View Coordinator duty auto-compaction stats"></a></h3><p>After the Coordinator has initiated auto-compaction, you can view compaction statistics for the datasource, including the number of bytes, segments, and intervals already compacted and those awaiting compaction. The Coordinator also reports the total bytes, segments, and intervals not eligible for compaction in accordance with its <a href="/docs/latest/design/coordinator#segment-search-policy-in-automatic-compaction">segment search policy</a>.</p><p>In the web console, the Datasources view displays auto-compaction statistics. The Tasks view shows the task information for compaction tasks that were triggered by the automatic compaction system.</p><p>To get statistics by API, send a <a href="/docs/latest/api-reference/automatic-compaction-api#view-automatic-compaction-status"><code>GET</code> request</a> to <code>/druid/coordinator/v1/compaction/status</code>. To filter the results to a particular datasource, pass the datasource name as a query parameter to the request—for example, <code>/druid/coordinator/v1/compaction/status?dataSource=wikipedia</code>.</p><h2 class="anchor anchorWithStickyNavbar_LWe7" id="avoid-conflicts-with-ingestion">Avoid conflicts with ingestion<a href="#avoid-conflicts-with-ingestion" class="hash-link" aria-label="Direct link to Avoid conflicts with ingestion" title="Direct link to Avoid conflicts with ingestion"></a></h2><p>Compaction tasks may be interrupted when they interfere with ingestion. For example, this occurs when an ingestion task needs to write data to a segment for a time interval locked for compaction. If there are continuous failures that prevent compaction from making progress, consider one of the following strategies:</p><ul><li>Enable <a href="#enable-concurrent-append-and-replace">concurrent append and replace tasks</a> on your datasource and on the ingestion tasks.</li><li>Set <code>skipOffsetFromLatest</code> to reduce the chance of conflicts between ingestion and compaction. See more details in <a href="#skip-compaction-for-latest-segments">Skip compaction for latest segments</a>.</li><li>Increase the priority value of compaction tasks relative to ingestion tasks. Only recommended for advanced users. This approach can cause ingestion jobs to fail or lag. To change the priority of compaction tasks, set <code>taskPriority</code> to the desired priority value in the auto-compaction configuration. For details on the priority values of different task types, see <a href="/docs/latest/ingestion/tasks#lock-priority">Lock priority</a>.</li></ul><h3 class="anchor anchorWithStickyNavbar_LWe7" id="enable-concurrent-append-and-replace">Enable concurrent append and replace<a href="#enable-concurrent-append-and-replace" class="hash-link" aria-label="Direct link to Enable concurrent append and replace" title="Direct link to Enable concurrent append and replace"></a></h3><p>You can use concurrent append and replace to safely replace the existing data in an interval of a datasource while new data is being appended to that interval even during compaction.</p><p>To do this, you need to update your datasource to allow concurrent append and replace tasks:</p><ul><li>If you&#x27;re using the API, include the following <code>taskContext</code> property in your API call: <code>&quot;useConcurrentLocks&quot;: true</code></li><li>If you&#x27;re using the UI, enable <strong>Use concurrent locks</strong> in the <strong>Compaction config</strong> for your datasource.</li></ul><p>You&#x27;ll also need to update your ingestion jobs for the datasource to include the task context <code>&quot;useConcurrentLocks&quot;: true</code>.</p><p>For information on how to do this, see <a href="/docs/latest/ingestion/concurrent-append-replace">Concurrent append and replace</a>.</p><h3 class="anchor anchorWithStickyNavbar_LWe7" id="skip-compaction-for-latest-segments">Skip compaction for latest segments<a href="#skip-compaction-for-latest-segments" class="hash-link" aria-label="Direct link to Skip compaction for latest segments" title="Direct link to Skip compaction for latest segments"></a></h3><p>The Coordinator compacts segments from newest to oldest. In the auto-compaction configuration, you can set a time period, relative to the end time of the most recent segment, for segments that should not be compacted. Assign this value to <code>skipOffsetFromLatest</code>. Note that this offset is not relative to the current time but to the latest segment time. For example, if you want to skip over segments from five days prior to the end time of the most recent segment, assign <code>&quot;skipOffsetFromLatest&quot;: &quot;P5D&quot;</code>.</p><p>To set <code>skipOffsetFromLatest</code>, consider how frequently you expect the stream to receive late arriving data. If your stream only occasionally receives late arriving data, the auto-compaction system robustly compacts your data even though data is ingested outside the <code>skipOffsetFromLatest</code> window. For most realtime streaming ingestion use cases, it is reasonable to set <code>skipOffsetFromLatest</code> to a few hours or a day.</p><h2 class="anchor anchorWithStickyNavbar_LWe7" id="examples">Examples<a href="#examples" class="hash-link" aria-label="Direct link to Examples" title="Direct link to Examples"></a></h2><p>The following examples demonstrate potential use cases in which auto-compaction may improve your Druid performance. See more details in <a href="/docs/latest/data-management/compaction#compaction-guidelines">Compaction strategies</a>. The examples in this section do not change the underlying data.</p><h3 class="anchor anchorWithStickyNavbar_LWe7" id="change-segment-granularity">Change segment granularity<a href="#change-segment-granularity" class="hash-link" aria-label="Direct link to Change segment granularity" title="Direct link to Change segment granularity"></a></h3><p>You have a stream set up to ingest data with <code>HOUR</code> segment granularity into the <code>wikistream</code> datasource. You notice that your Druid segments are smaller than the <a href="/docs/latest/operations/segment-optimization">recommended segment size</a> of 5 million rows per segment. You wish to automatically compact segments to <code>DAY</code> granularity while leaving the latest week of data <em>not</em> compacted because your stream consistently receives data within that time period.</p><p>The following auto-compaction configuration compacts existing <code>HOUR</code> segments into <code>DAY</code> segments while leaving the latest week of data not compacted:</p><div class="language-json codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#bfc7d5;--prism-background-color:#292d3e"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-json codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#bfc7d5"><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token property">&quot;dataSource&quot;</span><span class="token operator" style="color:rgb(137, 221, 255)">:</span><span class="token plain"> </span><span class="token string" style="color:rgb(195, 232, 141)">&quot;wikistream&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token property">&quot;granularitySpec&quot;</span><span class="token operator" style="color:rgb(137, 221, 255)">:</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token property">&quot;segmentGranularity&quot;</span><span class="token operator" style="color:rgb(137, 221, 255)">:</span><span class="token plain"> </span><span class="token string" style="color:rgb(195, 232, 141)">&quot;DAY&quot;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token property">&quot;skipOffsetFromLatest&quot;</span><span class="token operator" style="color:rgb(137, 221, 255)">:</span><span class="token plain"> </span><span class="token string" style="color:rgb(195, 232, 141)">&quot;P1W&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"></span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><h3 class="anchor anchorWithStickyNavbar_LWe7" id="update-partitioning-scheme">Update partitioning scheme<a href="#update-partitioning-scheme" class="hash-link" aria-label="Direct link to Update partitioning scheme" title="Direct link to Update partitioning scheme"></a></h3><p>For your <code>wikipedia</code> datasource, you want to optimize segment access when regularly ingesting data without compromising compute time when querying the data. Your ingestion spec for batch append uses <a href="/docs/latest/ingestion/native-batch#dynamic-partitioning">dynamic partitioning</a> to optimize for write-time operations, while your stream ingestion partitioning is configured by the stream service. You want to implement auto-compaction to reorganize the data with a suitable read-time partitioning using <a href="/docs/latest/ingestion/native-batch#multi-dimension-range-partitioning">multi-dimension range partitioning</a>. Based on the dimensions frequently accessed in queries, you wish to partition on the following dimensions: <code>channel</code>, <code>countryName</code>, <code>namespace</code>.</p><p>The following auto-compaction configuration compacts updates the <code>wikipedia</code> segments to use multi-dimension range partitioning:</p><div class="language-json codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#bfc7d5;--prism-background-color:#292d3e"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-json codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#bfc7d5"><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token property">&quot;dataSource&quot;</span><span class="token operator" style="color:rgb(137, 221, 255)">:</span><span class="token plain"> </span><span class="token string" style="color:rgb(195, 232, 141)">&quot;wikipedia&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token property">&quot;tuningConfig&quot;</span><span class="token operator" style="color:rgb(137, 221, 255)">:</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token property">&quot;partitionsSpec&quot;</span><span class="token operator" style="color:rgb(137, 221, 255)">:</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token property">&quot;type&quot;</span><span class="token operator" style="color:rgb(137, 221, 255)">:</span><span class="token plain"> </span><span class="token string" style="color:rgb(195, 232, 141)">&quot;range&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token property">&quot;partitionDimensions&quot;</span><span class="token operator" style="color:rgb(137, 221, 255)">:</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">[</span><span class="token plain"></span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token string" style="color:rgb(195, 232, 141)">&quot;channel&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token string" style="color:rgb(195, 232, 141)">&quot;countryName&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token string" style="color:rgb(195, 232, 141)">&quot;namespace&quot;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">]</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token property">&quot;targetRowsPerSegment&quot;</span><span class="token operator" style="color:rgb(137, 221, 255)">:</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">5000000</span><span class="token plain"></span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token plain"></span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token plain"></span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"></span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><h2 class="anchor anchorWithStickyNavbar_LWe7" id="auto-compaction-using-compaction-supervisors">Auto-compaction using compaction supervisors<a href="#auto-compaction-using-compaction-supervisors" class="hash-link" aria-label="Direct link to Auto-compaction using compaction supervisors" title="Direct link to Auto-compaction using compaction supervisors"></a></h2><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>Experimental</div><div class="admonitionContent_S0QG"><p>Compaction supervisors are experimental. For production use, we recommend <a href="#auto-compaction-using-coordinator-duties">auto-compaction using Coordinator duties</a>.</p></div></div><p>You can run automatic compaction using compaction supervisors on the Overlord rather than Coordinator duties. Compaction supervisors provide the following benefits over Coordinator duties:</p><ul><li>Can use the supervisor framework to get information about the auto-compaction, such as status or state</li><li>More easily suspend or resume compaction for a datasource</li><li>Can use either the native compaction engine or the <a href="#use-msq-for-auto-compaction">MSQ task engine</a></li><li>More reactive and submits tasks as soon as a compaction slot is available</li><li>Tracked compaction task status to avoid re-compacting an interval repeatedly</li></ul><p>To use compaction supervisors, set the following properties in your Overlord runtime properties:</p><ul><li><code>druid.supervisor.compaction.enabled</code> to <code>true</code> so that compaction tasks can be run as supervisor tasks</li><li><code>druid.supervisor.compaction.engine</code> to <code>msq</code> to specify the MSQ task engine as the compaction engine or to <code>native</code> to use the native engine. This is the default engine if the <code>engine</code> field is omitted from your compaction config</li></ul><p>Compaction supervisors use the same syntax as auto-compaction using Coordinator duties with one key difference: you submit the auto-compaction as a a supervisor spec. In the spec, set the <code>type</code> to <code>autocompact</code> and include the auto-compaction config in the <code>spec</code>.</p><p>To submit an automatic compaction task, you can submit a supervisor spec through the <a href="#manage-compaction-supervisors-with-the-web-console">web console</a> or the <a href="#manage-compaction-supervisors-with-supervisor-apis">supervisor API</a>.</p><h3 class="anchor anchorWithStickyNavbar_LWe7" id="manage-compaction-supervisors-with-the-web-console">Manage compaction supervisors with the web console<a href="#manage-compaction-supervisors-with-the-web-console" class="hash-link" aria-label="Direct link to Manage compaction supervisors with the web console" title="Direct link to Manage compaction supervisors with the web console"></a></h3><p>To submit a supervisor spec for MSQ task engine automatic compaction, perform the following steps:</p><ol><li>In the web console, go to the <strong>Supervisors</strong> tab.</li><li>Click <strong>...</strong> &gt; <strong>Submit JSON supervisor</strong>.</li><li>In the dialog, include the following:<ul><li>The type of supervisor spec by setting <code>&quot;type&quot;: &quot;autocompact&quot;</code></li><li>The compaction configuration by adding it to the <code>spec</code> field</li></ul><div class="language-json codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#bfc7d5;--prism-background-color:#292d3e"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-json codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#bfc7d5"><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token property">&quot;type&quot;</span><span class="token operator" style="color:rgb(137, 221, 255)">:</span><span class="token plain"> </span><span class="token string" style="color:rgb(195, 232, 141)">&quot;autocompact&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token property">&quot;spec&quot;</span><span class="token operator" style="color:rgb(137, 221, 255)">:</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token property">&quot;dataSource&quot;</span><span class="token operator" style="color:rgb(137, 221, 255)">:</span><span class="token plain"> YOUR_DATASOURCE</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token property">&quot;tuningConfig&quot;</span><span class="token operator" style="color:rgb(137, 221, 255)">:</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain">...</span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token property">&quot;granularitySpec&quot;</span><span class="token operator" style="color:rgb(137, 221, 255)">:</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain">...</span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token property">&quot;engine&quot;</span><span class="token operator" style="color:rgb(137, 221, 255)">:</span><span class="token plain"> &lt;native|msq&gt;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> ...</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"></span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div></li><li>Submit the supervisor.</li></ol><p>To stop the automatic compaction task, suspend or terminate the supervisor through the UI or API.</p><h3 class="anchor anchorWithStickyNavbar_LWe7" id="manage-compaction-supervisors-with-supervisor-apis">Manage compaction supervisors with supervisor APIs<a href="#manage-compaction-supervisors-with-supervisor-apis" class="hash-link" aria-label="Direct link to Manage compaction supervisors with supervisor APIs" title="Direct link to Manage compaction supervisors with supervisor APIs"></a></h3><p>Submitting an automatic compaction as a supervisor task uses the same endpoint as supervisor tasks for streaming ingestion.</p><p>The following example configures auto-compaction for the <code>wikipedia</code> datasource:</p><div class="language-sh codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#bfc7d5;--prism-background-color:#292d3e"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-sh codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#bfc7d5"><span class="token plain">curl --location --request POST &#x27;http://localhost:8081/druid/indexer/v1/supervisor&#x27; \</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain">--header &#x27;Content-Type: application/json&#x27; \</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain">--data-raw &#x27;{</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> &quot;type&quot;: &quot;autocompact&quot;, // required</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> &quot;suspended&quot;: false, // optional </span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> &quot;spec&quot;: { // required</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> &quot;dataSource&quot;: &quot;wikipedia&quot;, // required</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> &quot;tuningConfig&quot;: {...}, // optional</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> &quot;granularitySpec&quot;: {...}, // optional</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> &quot;engine&quot;: &lt;native|msq&gt;, // optional</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> ...</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> }</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain">}&#x27;</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><p>Note that if you omit <code>spec.engine</code>, Druid uses the default compaction engine. You can control the default compaction engine with the <code>druid.supervisor.compaction.engine</code> Overlord runtime property. If <code>spec.engine</code> and <code>druid.supervisor.compaction.engine</code> are omitted, Druid defaults to the native engine.</p><p>To stop the automatic compaction task, suspend or terminate the supervisor through the UI or API.</p><h3 class="anchor anchorWithStickyNavbar_LWe7" id="use-msq-for-auto-compaction">Use MSQ for auto-compaction<a href="#use-msq-for-auto-compaction" class="hash-link" aria-label="Direct link to Use MSQ for auto-compaction" title="Direct link to Use MSQ for auto-compaction"></a></h3><p>The MSQ task engine is available as a compaction engine if you configure auto-compaction to use compaction supervisors. To use the MSQ task engine for automatic compaction, make sure the following requirements are met:</p><ul><li><a href="/docs/latest/multi-stage-query/#load-the-extension">Load the MSQ task engine extension</a>.</li><li>In your Overlord runtime properties, set the following properties:<ul><li><code>druid.supervisor.compaction.enabled</code> to <code>true</code> so that compaction tasks can be run as a supervisor task.</li><li>Optionally, set <code>druid.supervisor.compaction.engine</code> to <code>msq</code> to specify the MSQ task engine as the default compaction engine. If you don&#x27;t do this, you&#x27;ll need to set <code>spec.engine</code> to <code>msq</code> for each compaction supervisor spec where you want to use the MSQ task engine.</li></ul></li><li>Have at least two compaction task slots available or set <code>compactionConfig.taskContext.maxNumTasks</code> to two or more. The MSQ task engine requires at least two tasks to run, one controller task and one worker task.</li></ul><p>You can use <a href="/docs/latest/multi-stage-query/reference#context-parameters">MSQ task engine context parameters</a> in <code>spec.taskContext</code> when configuring your datasource for automatic compaction, such as setting the maximum number of tasks using the <code>spec.taskContext.maxNumTasks</code> parameter. Some of the MSQ task engine context parameters overlap with automatic compaction parameters. When these settings overlap, set one or the other.</p><h4 class="anchor anchorWithStickyNavbar_LWe7" id="msq-task-engine-limitations">MSQ task engine limitations<a href="#msq-task-engine-limitations" class="hash-link" aria-label="Direct link to MSQ task engine limitations" title="Direct link to MSQ task engine limitations"></a></h4><p>When using the MSQ task engine for auto-compaction, keep the following limitations in mind:</p><ul><li>The <code>metricSpec</code> field is only supported for certain aggregators. For more information, see <a href="#supported-aggregators">Supported aggregators</a>.</li><li>Only dynamic and range-based partitioning are supported.</li><li>Set <code>rollup</code> to <code>true</code> if and only if <code>metricSpec</code> is not empty or null.</li><li>You can only partition on string dimensions. However, multi-valued string dimensions are not supported.</li><li>The <code>maxTotalRows</code> config is not supported in <code>DynamicPartitionsSpec</code>. Use <code>maxRowsPerSegment</code> instead.</li><li>Segments can only be sorted on <code>__time</code> as the first column.</li></ul><h4 class="anchor anchorWithStickyNavbar_LWe7" id="supported-aggregators">Supported aggregators<a href="#supported-aggregators" class="hash-link" aria-label="Direct link to Supported aggregators" title="Direct link to Supported aggregators"></a></h4><p>Auto-compaction using the MSQ task engine supports only aggregators that satisfy the following properties: </p><ul><li><strong>Mergeability</strong>: can combine partial aggregates</li><li><strong>Idempotency</strong>: produces the same results on repeated runs of the aggregator on previously aggregated values in a column</li></ul><p>This is exemplified by the following <code>longSum</code> aggregator:</p><div class="codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#bfc7d5;--prism-background-color:#292d3e"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-text codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#bfc7d5"><span class="token plain">{&quot;name&quot;: &quot;added&quot;, &quot;type&quot;: &quot;longSum&quot;, &quot;fieldName&quot;: &quot;added&quot;}</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><p>where <code>longSum</code> being capable of combining partial results satisfies mergeability, while input and output column being the same (<code>added</code>) ensures idempotency.</p><p>The following are some examples of aggregators that aren&#x27;t supported since at least one of the required conditions aren&#x27;t satisfied:</p><ul><li><code>longSum</code> aggregator where the <code>added</code> column rolls up into <code>sum_added</code> column discarding the input <code>added</code> column, violating idempotency, as subsequent runs would no longer find the <code>added</code> column:<div class="codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#bfc7d5;--prism-background-color:#292d3e"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-text codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#bfc7d5"><span class="token plain">{&quot;name&quot;: &quot;sum_added&quot;, &quot;type&quot;: &quot;longSum&quot;, &quot;fieldName&quot;: &quot;added&quot;}</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div></li><li>Partial sketches which cannot themselves be used to combine partial aggregates and need merging aggregators -- such as <code>HLLSketchMerge</code> required for <code>HLLSketchBuild</code> aggregator below -- violating mergeability:<div class="codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#bfc7d5;--prism-background-color:#292d3e"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-text codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#bfc7d5"><span class="token plain">{&quot;name&quot;: &quot;added&quot;, &quot;type&quot;: &quot;HLLSketchBuild&quot;, &quot;fieldName&quot;: &quot;added&quot;}</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div></li><li>Count aggregator since it cannot be used to combine partial aggregates and it rolls up into a different <code>count</code> column discarding the input column(s), violating both mergeability and idempotency.<div class="codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#bfc7d5;--prism-background-color:#292d3e"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-text codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#bfc7d5"><span class="token plain">{&quot;type&quot;: &quot;count&quot;, &quot;name&quot;: &quot;count&quot;}</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div></li></ul><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/latest/data-management/compaction">Compaction</a> for an overview of compaction in Druid.</li><li><a href="/docs/latest/data-management/manual-compaction">Manual compaction</a> for how to manually perform compaction tasks.</li><li><a href="/docs/latest/operations/segment-optimization">Segment optimization</a> for guidance on evaluating and optimizing Druid segment size.</li><li><a href="/docs/latest/design/coordinator#automatic-compaction">Coordinator process</a> for details on how the Coordinator plans compaction tasks.</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/latest/data-management/compaction"><div class="pagination-nav__sublabel">Previous</div><div class="pagination-nav__label">Compaction</div></a><a class="pagination-nav__link pagination-nav__link--next" href="/docs/latest/data-management/manual-compaction"><div class="pagination-nav__sublabel">Next</div><div class="pagination-nav__label">Manual compaction</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="#auto-compaction-syntax" class="table-of-contents__link toc-highlight">Auto-compaction syntax</a></li><li><a href="#auto-compaction-using-coordinator-duties" class="table-of-contents__link toc-highlight">Auto-compaction using Coordinator duties</a><ul><li><a href="#manage-auto-compaction-using-the-web-console" class="table-of-contents__link toc-highlight">Manage auto-compaction using the web console</a></li><li><a href="#manage-auto-compaction-using-coordinator-apis" class="table-of-contents__link toc-highlight">Manage auto-compaction using Coordinator APIs</a></li><li><a href="#change-compaction-frequency" class="table-of-contents__link toc-highlight">Change compaction frequency</a></li><li><a href="#view-coordinator-duty-auto-compaction-stats" class="table-of-contents__link toc-highlight">View Coordinator duty auto-compaction stats</a></li></ul></li><li><a href="#avoid-conflicts-with-ingestion" class="table-of-contents__link toc-highlight">Avoid conflicts with ingestion</a><ul><li><a href="#enable-concurrent-append-and-replace" class="table-of-contents__link toc-highlight">Enable concurrent append and replace</a></li><li><a href="#skip-compaction-for-latest-segments" class="table-of-contents__link toc-highlight">Skip compaction for latest segments</a></li></ul></li><li><a href="#examples" class="table-of-contents__link toc-highlight">Examples</a><ul><li><a href="#change-segment-granularity" class="table-of-contents__link toc-highlight">Change segment granularity</a></li><li><a href="#update-partitioning-scheme" class="table-of-contents__link toc-highlight">Update partitioning scheme</a></li></ul></li><li><a href="#auto-compaction-using-compaction-supervisors" class="table-of-contents__link toc-highlight">Auto-compaction using compaction supervisors</a><ul><li><a href="#manage-compaction-supervisors-with-the-web-console" class="table-of-contents__link toc-highlight">Manage compaction supervisors with the web console</a></li><li><a href="#manage-compaction-supervisors-with-supervisor-apis" class="table-of-contents__link toc-highlight">Manage compaction supervisors with supervisor APIs</a></li><li><a href="#use-msq-for-auto-compaction" class="table-of-contents__link toc-highlight">Use MSQ for auto-compaction</a></li></ul></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.b5a26022.js"></script>
<script src="/assets/js/main.9dc00f46.js"></script>
</body>
</html>