{"title":"Choose compute for a query","description":"Choose automatic or fixed compute sizing for lakehouse queries, understand available Worker tiers, and account for session reuse constraints.","order":100,"askSuggestions":["When should I use a fixed compute size instead of AUTO?","Why can't I use AUTO with a session ID?"],"navigation":true,"body":{"code":"var Component=(()=>{var p=Object.create;var t=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var w=Object.getPrototypeOf,y=Object.prototype.hasOwnProperty;var T=(o,e)=>()=>(e||o((e={exports:{}}).exports,e),e.exports),g=(o,e)=>{for(var r in e)t(o,r,{get:e[r],enumerable:!0})},c=(o,e,r,i)=>{if(e&&typeof e==\"object\"||typeof e==\"function\")for(let s of f(e))!y.call(o,s)&&s!==r&&t(o,s,{get:()=>e[s],enumerable:!(i=m(e,s))||i.enumerable});return o};var x=(o,e,r)=>(r=o!=null?p(w(o)):{},c(e||!o||!o.__esModule?t(r,\"default\",{value:o,enumerable:!0}):r,o)),z=o=>c(t({},\"__esModule\",{value:!0}),o);var d=T((S,l)=>{l.exports=_jsx_runtime});var k={};g(k,{default:()=>u,frontmatter:()=>b});var n=x(d()),b={title:\"Choose compute for a query\",description:\"Choose automatic or fixed compute sizing for lakehouse queries, understand available Worker tiers, and account for session reuse constraints.\",order:100,askSuggestions:[\"When should I use a fixed compute size instead of AUTO?\",\"Why can't I use AUTO with a session ID?\"]};function h(o){let e={code:\"code\",h1:\"h1\",h2:\"h2\",li:\"li\",p:\"p\",pre:\"pre\",strong:\"strong\",ul:\"ul\",...o.components},{DocsPreviewDocument:r,DocsPreviewSection:i,DocsTable:s}=e;return r||a(\"DocsPreviewDocument\",!0),i||a(\"DocsPreviewSection\",!0),s||a(\"DocsTable\",!0),(0,n.jsxs)(r,{anchors:\"choose-compute-for-a-query how-auto-works fixed-sizes\",children:[(0,n.jsxs)(i,{sectionId:\"choose-compute-for-a-query\",anchors:\"\",ancestors:\"\",index:\"0\",children:[(0,n.jsx)(e.h1,{id:\"choose-compute-for-a-query\",children:\"Choose compute for a query\"}),`\n`,(0,n.jsx)(e.p,{children:\"Without per-query sizing, every statement can run on the same compute profile\\u2014whether it scans ten rows or ten billion.\"}),`\n`,(0,n.jsxs)(e.p,{children:[\"Pass \",(0,n.jsx)(e.code,{children:'\"compute_size\": \"AUTO\"'}),\" (the default in SQL Explorer) and Altertable picks a size \",(0,n.jsx)(e.strong,{children:\"per query\"}),\" from the SQL itself. A narrow \",(0,n.jsx)(e.code,{children:\"LIMIT 100\"}),\" over a large table can run on \",(0,n.jsx)(e.code,{children:\"XS\"}),\"; a full-table aggregate may need \",(0,n.jsx)(e.code,{children:\"XL\"}),\".\"]}),`\n`,(0,n.jsx)(e.pre,{children:(0,n.jsx)(e.code,{className:\"language-json\",children:`{\n  \"statement\": \"SELECT id, email FROM users WHERE created_at > now() - interval '7 days' LIMIT 100\",\n  \"compute_size\": \"AUTO\"\n}\n`})}),`\n`]}),(0,n.jsxs)(i,{sectionId:\"how-auto-works\",anchors:\"\",ancestors:\"\",index:\"1\",children:[(0,n.jsxs)(e.h2,{id:\"how-auto-works\",children:[\"How \",(0,n.jsx)(e.code,{children:\"AUTO\"}),\" works\"]}),`\n`,(0,n.jsxs)(e.p,{children:[\"Before execution, Altertable runs \",(0,n.jsx)(e.code,{children:\"EXPLAIN\"}),\" on the statement and walks the physical plan to estimate how much parallelism the query needs. It then selects the smallest tier that fits:\"]}),`\n`,(0,n.jsx)(s,{columns:[\"Size\",\"Threads\",\"Typical fit\"],data:[{Size:\"`XS`\",Threads:\"2\",\"Typical fit\":\"Point lookups, small scans, queries with early `LIMIT`\"},{Size:\"`S`\",Threads:\"4\",\"Typical fit\":\"Moderate scans\"},{Size:\"`M`\",Threads:\"8\",\"Typical fit\":\"Larger scans or joins\"},{Size:\"`L`\",Threads:\"16\",\"Typical fit\":\"Heavy joins or aggregations\"},{Size:\"`XL`\",Threads:\"32\",\"Typical fit\":\"Full-table scans and large shuffles\"},{Size:\"`2XL`\",Threads:\"64\",\"Typical fit\":\"Large parallel workloads\"},{Size:\"`3XL`\",Threads:\"96\",\"Typical fit\":\"Large parallel workloads\"},{Size:\"`4XL`\",Threads:\"128\",\"Typical fit\":\"Large parallel workloads\"}]}),`\n`,(0,n.jsx)(e.p,{children:(0,n.jsx)(e.strong,{children:\"Constraints:\"})}),`\n`,(0,n.jsxs)(e.ul,{children:[`\n`,(0,n.jsxs)(e.li,{children:[(0,n.jsx)(e.code,{children:\"AUTO\"}),\" cannot be combined with an explicit \",(0,n.jsx)(e.code,{children:\"session_id\"}),\". Reuse sessions when you need temporary state; pick a fixed size when you need both session reuse and predictable compute.\"]}),`\n`]}),`\n`,(0,n.jsx)(e.p,{children:\"Requested sizes cannot exceed the environment\\u2019s provider maximum. Actual allocation can be lower when compute allowances are constrained.\"}),`\n`]}),(0,n.jsxs)(i,{sectionId:\"fixed-sizes\",anchors:\"\",ancestors:\"\",index:\"2\",children:[(0,n.jsx)(e.h2,{id:\"fixed-sizes\",children:\"Fixed sizes\"}),`\n`,(0,n.jsx)(e.p,{children:\"Override inference when you know the workload or need repeatable performance:\"}),`\n`,(0,n.jsx)(e.pre,{children:(0,n.jsx)(e.code,{className:\"language-json\",children:`{\n  \"statement\": \"SELECT ...\",\n  \"compute_size\": \"M\"\n}\n`})}),`\n`,(0,n.jsx)(e.p,{children:\"Use a fixed tier for long-running batch jobs, dashboards that should always warm the same worker profile, or queries where you have already benchmarked the right size.\"})]})]})}function u(o={}){let{wrapper:e}=o.components||{};return e?(0,n.jsx)(e,{...o,children:(0,n.jsx)(h,{...o})}):h(o)}function a(o,e){throw new Error(\"Expected \"+(e?\"component\":\"object\")+\" `\"+o+\"` to be defined: you likely forgot to import, pass, or provide it.\")}return z(k);})();\n;return Component;"},"_id":"docs/lakehouse/compute/sizing.mdx","_raw":{"sourceFilePath":"docs/lakehouse/compute/sizing.mdx","sourceFileName":"sizing.mdx","sourceFileDir":"docs/lakehouse/compute","contentType":"mdx","flattenedPath":"docs/lakehouse/compute/sizing"},"type":"Docs","path":"/lakehouse/compute/sizing","level":3,"parent":"lakehouse/compute"}