<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: ai-query Execution in Generative AI</title>
    <link>https://community.databricks.com/t5/generative-ai/ai-query-execution/m-p/177726#M2315</link>
    <description>&lt;P&gt;Sure, happy to. I hope this gives a bit more details and makes it a bit clearer&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;The second level is about where the model inference itself runs, separately from the Spark compute that runs your query.&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;STRONG&gt;Two layers, billed separately&lt;/STRONG&gt;&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Your cluster, serverless compute or Pro/Serverless SQL warehouse runs the query (AI Functions aren't available on Classic SQL warehouses). It reads the rows, builds the prompts and writes the results. Each &lt;SPAN&gt;ai_query&lt;/SPAN&gt;&lt;SPAN&gt; call goes to Model Serving, which runs the LLM inference. For Databricks-hosted models you don't create or size an endpoint. The docs describe them as "provisionless endpoints [that] are fully managed and work best for batch processing."&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;So you see cost in two places: the compute running the query, and the inference.&lt;/STRONG&gt; Per the AI Functions docs, batch inference is recorded in &lt;/SPAN&gt;&lt;SPAN&gt;system.billing.usage&lt;/SPAN&gt;&lt;SPAN&gt; as &lt;/SPAN&gt;&lt;SPAN&gt;MODEL_SERVING&lt;/SPAN&gt;&lt;SPAN&gt; with offering type &lt;/SPAN&gt;&lt;SPAN&gt;BATCH_INFERENCE&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;SELECT usage_date, sku_name, SUM(usage_quantity) AS dbus

FROM system.billing.usage

WHERE billing_origin_product = 'MODEL_SERVING'

  AND product_features.model_serving.offering_type = 'BATCH_INFERENCE'

GROUP BY ALL

ORDER BY usage_date DESC;&lt;/LI-CODE&gt;
&lt;OL start="2"&gt;
&lt;LI&gt;&lt;STRONG&gt; What "managed scaling" means for you&lt;/STRONG&gt;&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&lt;SPAN&gt;According the documentation "AI Functions automatically handle parallelisation, retries, and scaling." &lt;BR /&gt;In practice:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&lt;STRONG&gt;It sends the full dataset in one query.&lt;/STRONG&gt;&lt;SPAN&gt; Manually splitting it into small batches can reduce throughput.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&lt;STRONG&gt;Retries are handled for you.&lt;/STRONG&gt;&lt;SPAN&gt; With &lt;/SPAN&gt;&lt;SPAN&gt;failOnError =&amp;gt; false&lt;/SPAN&gt;&lt;SPAN&gt;, each row returns a struct with &lt;/SPAN&gt;&lt;SPAN&gt;response&lt;/SPAN&gt;&lt;SPAN&gt; and &lt;/SPAN&gt;&lt;SPAN&gt;errorMessage&lt;/SPAN&gt;&lt;SPAN&gt;. Rows that fail on a model endpoint error get a null &lt;/SPAN&gt;&lt;SPAN&gt;response&lt;/SPAN&gt;&lt;SPAN&gt; plus the error, instead of failing the whole job, so you can re-run just those rows later. Other kinds of errors still fail the query.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&lt;STRONG&gt;The docs describe no tuning settings&lt;/STRONG&gt;&lt;SPAN&gt; (concurrency, replicas and so on) for this path. They also note that "performance may not scale linearly from very small workloads to large-scale workloads", so benchmark on a realistic sample, not a few rows.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;OL start="3"&gt;
&lt;LI&gt;&lt;STRONG&gt; Which endpoint you call matters&lt;/STRONG&gt;&lt;/LI&gt;
&lt;/OL&gt;
&lt;UL&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&lt;STRONG&gt;Databricks-hosted models optimized for batch: recommended.&lt;/STRONG&gt;&lt;SPAN&gt; "Databricks optimizes specific models for high-throughput batch workloads." The list is on the ai_query page (for example &lt;/SPAN&gt;&lt;SPAN&gt;system.ai.gpt-5-2&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;system.ai.gemini-3-1-pro&lt;/SPAN&gt;&lt;SPAN&gt;). Other hosted models work but may give lower throughput and longer runs.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&lt;STRONG&gt;Provisioned throughput endpoints:&lt;/STRONG&gt; &lt;SPAN&gt;ai_query&lt;/SPAN&gt;&lt;SPAN&gt; can call them, but "AI Functions does not use the compute provisioned to the endpoint" and "fully manages the scaling used for batch inference". So sizing up a provisioned endpoint won't speed up batch &lt;/SPAN&gt;&lt;SPAN&gt;ai_query&lt;/SPAN&gt;&lt;SPAN&gt;, and the docs recommend Databricks-hosted models instead.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&lt;STRONG&gt;Rate limits:&lt;/STRONG&gt;&lt;SPAN&gt; the published pay-per-token limits (input/output tokens per minute, requests per hour) apply to pay-per-token endpoints. The docs don't say how they apply to batch AI Functions, so don't size a batch job from those numbers.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&lt;STRONG&gt;Custom model endpoints:&lt;/STRONG&gt; &lt;SPAN&gt;ai_query&lt;/SPAN&gt;&lt;SPAN&gt; supports them, and they're billed as their own serving endpoint.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&lt;STRONG&gt;Back to the practical steps&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;OL start="4"&gt;
&lt;LI&gt;&lt;STRONG&gt;Practical checklist&lt;/STRONG&gt;&lt;/LI&gt;
&lt;/OL&gt;
&lt;UL&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&lt;SPAN&gt;Pick a model from the batch-optimized list.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&lt;SPAN&gt;Save the results once with &lt;/SPAN&gt;&lt;SPAN&gt;CREATE OR REPLACE TABLE ... AS SELECT ai_query(...)&lt;/SPAN&gt;&lt;SPAN&gt;, then query that table.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&lt;SPAN&gt;Set &lt;/SPAN&gt;&lt;SPAN&gt;failOnError =&amp;gt; false&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&lt;SPAN&gt;Watch progress in the query profile, and cost in &lt;/SPAN&gt;&lt;SPAN&gt;system.billing.usage&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&lt;SPAN&gt;Docs: &lt;/SPAN&gt;&lt;A href="https://docs.databricks.com/aws/en/large-language-models/ai-functions" target="_blank"&gt;&lt;SPAN&gt;AI Functions&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt; · &lt;/SPAN&gt;&lt;A href="https://docs.databricks.com/aws/en/large-language-models/ai-query" target="_blank"&gt;&lt;SPAN&gt;ai_query&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt; · &lt;/SPAN&gt;&lt;A href="https://docs.databricks.com/aws/en/sql/language-manual/functions/ai_query" target="_blank"&gt;&lt;SPAN&gt;ai_query function reference&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt; · &lt;/SPAN&gt;&lt;A href="https://docs.databricks.com/aws/en/machine-learning/foundation-model-apis/limits" target="_blank"&gt;&lt;SPAN&gt;Foundation Model API limits&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 26 Nov 2026 15:43:06 GMT</pubDate>
    <dc:creator>Valeria_Koz_DBX</dc:creator>
    <dc:date>2026-11-26T15:43:06Z</dc:date>
    <item>
      <title>ai-query Execution</title>
      <link>https://community.databricks.com/t5/generative-ai/ai-query-execution/m-p/177469#M2293</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I see that ai-query supports parallelization. Is it executed in parallel across each partition of the dataframe.&lt;BR /&gt;could any one explain how it supports optimized batch inference&lt;/P&gt;</description>
      <pubDate>Tue, 24 Nov 2026 17:30:46 GMT</pubDate>
      <guid>https://community.databricks.com/t5/generative-ai/ai-query-execution/m-p/177469#M2293</guid>
      <dc:creator>IM_01</dc:creator>
      <dc:date>2026-11-24T17:30:46Z</dc:date>
    </item>
    <item>
      <title>Re: ai-query Execution</title>
      <link>https://community.databricks.com/t5/generative-ai/ai-query-execution/m-p/177489#M2295</link>
      <description>&lt;PRE&gt;Hi &lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/193958"&gt;@IM_01&lt;/a&gt;,

ai_query is built for batch inference, but the docs do not say that it runs one call per DataFrame partition, and they do not describe the internal batching. They say the platform manages it. The AI Functions page says: "AI Functions automatically manage parallelization, retries, and scaling. It is advised to submit your full dataset in a single query rather than manually splitting it into small batches."

The same page says "your query runs on the compute you submit it from, such as a SQL warehouse, notebook, cluster, or pipeline", and that "the model inference may run on separate Databricks-managed infrastructure". So the docs do not link the number of partitions to the number of parallel model calls, and I would not tune partitions for this.

For optimised batch inference, the best practices on the "Use ai_query" page are:
1) Use Databricks-hosted system.ai model services, not provisioned throughput endpoints.
2) Pick a model from the batch-optimised list on that page. A non-optimised model "can result in reduced throughput and longer job completion times."
3) Submit your full dataset in a single query. "Manually splitting data into small batches can reduce throughput."
4) Set failOnError to false for large workloads, so failed rows return an error message and you keep the successful results.
&lt;BR /&gt;[&lt;A href="https://docs.databricks.com/aws/en/large-language-models/ai-query]" target="_blank" rel="noopener"&gt;https://docs.databricks.com/aws/en/large-language-models/ai-query]&lt;/A&gt;&lt;BR /&gt;
To see what happened in a run, open the query profile in the SQL editor and click AI Query. It shows the completed and failed inferences and the total time.&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 Nov 2026 02:33:07 GMT</pubDate>
      <guid>https://community.databricks.com/t5/generative-ai/ai-query-execution/m-p/177489#M2295</guid>
      <dc:creator>sundar-sg</dc:creator>
      <dc:date>2026-11-25T02:33:07Z</dc:date>
    </item>
    <item>
      <title>Re: ai-query Execution</title>
      <link>https://community.databricks.com/t5/generative-ai/ai-query-execution/m-p/177490#M2296</link>
      <description>&lt;PRE&gt;Hi &lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/193958"&gt;@IM_01&lt;/a&gt;,

ai_query is built for batch inference, but the docs do not say that it runs one call per DataFrame partition, and they do not describe the internal batching. They say the platform manages it. The AI Functions page says: "AI Functions automatically manage parallelization, retries, and scaling. It is advised to submit your full dataset in a single query rather than manually splitting it into small batches."

The same page says "your query runs on the compute you submit it from, such as a SQL warehouse, notebook, cluster, or pipeline", and that "the model inference may run on separate Databricks-managed infrastructure". So the docs do not link the number of partitions to the number of parallel model calls, and I would not tune partitions for this.

For optimised batch inference, the best practices on the "Use ai_query" page are:
1) Use Databricks-hosted system.ai model services, not provisioned throughput endpoints.
2) Pick a model from the batch-optimised list on that page. A non-optimised model "can result in reduced throughput and longer job completion times."
3) Submit your full dataset in a single query. "Manually splitting data into small batches can reduce throughput."
4) Set failOnError to false for large workloads, so failed rows return an error message and you keep the successful results.
&lt;BR /&gt;[&lt;A href="https://docs.databricks.com/aws/en/large-language-models/ai-query]" rel="noopener" target="_blank"&gt;https://docs.databricks.com/aws/en/large-language-models/ai-query]&lt;/A&gt;&lt;BR /&gt;
To see what happened in a run, open the query profile in the SQL editor and click AI Query. It shows the completed and failed inferences and the total time.&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 Nov 2026 02:35:34 GMT</pubDate>
      <guid>https://community.databricks.com/t5/generative-ai/ai-query-execution/m-p/177490#M2296</guid>
      <dc:creator>Yougasundar</dc:creator>
      <dc:date>2026-11-25T02:35:34Z</dc:date>
    </item>
    <item>
      <title>Re: ai-query Execution</title>
      <link>https://community.databricks.com/t5/generative-ai/ai-query-execution/m-p/177631#M2310</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/193958"&gt;@IM_01&lt;/a&gt;&amp;nbsp;,&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Short answer:&lt;/STRONG&gt; yes, ai_query works in parallel, but partitions aren't really the lever. Parallelism happens at two levels, and Databricks manages the important one for you.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;1. Spark side (your DataFrame)&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;ai_query&lt;/STRONG&gt; is evaluated like any other Spark SQL expression, so rows are processed by Spark tasks, and partitions are processed in parallel across the cluster's cores. In most cases Spark sizes the partitions adaptively, so you don't need to tune anything.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;2. Model-serving side (where the optimised batch inference happens)&lt;/STRONG&gt;&lt;BR /&gt;This is usually the real bottleneck, and AI Functions "automatically handle paralleliation, retries, and scaling" for it. With a batch-optimised Databricks-hosted model, the batch backend scales capacity up for your query automatically. You don't provision or configure endpoint compute.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Should I repartition?&lt;/STRONG&gt;&lt;BR /&gt;Usually no. The docs advise submitting your full dataset in a single query and warn that "manually splitting data into small batches can reduce throughput." The exception is input that is clearly under-partitioned, such as a small CSV read into one or two partitions on classic compute with idle cores. There, a modest repartition(n) with n roughly equal to the available cores can help. Benchmark it: too many partitions gives diminishing returns, and repartitioning doesn't change cost.&lt;/P&gt;
&lt;P&gt;How to get the optimised batch path:First, make sure:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Run on DBR 15.4 LTS+ (18.2+ recommended, and note the announced move to 17.3 LTS as the minimum). Not available on Classic SQL warehouses.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Then follow the steps that were mentioned in the previous comments:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Use a &lt;STRONG&gt;system.ai (Databricks-hosted) model&lt;/STRONG&gt; from the batch-optimised list, not a provisioned-throughput or custom endpoint.&lt;/LI&gt;
&lt;LI&gt;&amp;nbsp;Send the whole dataset in one query&lt;BR /&gt;&lt;LI-CODE lang="python"&gt;CREATE OR REPLACE TABLE results AS
SELECT id, ai_query('databricks-…', prompt, failOnError =&amp;gt; false) AS ai
FROM source;​&lt;/LI-CODE&gt;&lt;STRONG&gt;Use one ai_query session per model&lt;/STRONG&gt; rather than several running side by side. Persist the results to a table instead of re-running inference in later queries.&lt;/LI&gt;
&lt;LI&gt;Set&lt;EM&gt;&lt;STRONG&gt; failOnError =&amp;gt; false&lt;/STRONG&gt;&lt;/EM&gt; for large workloads. You get a &lt;STRONG&gt;STRUCT&lt;/STRONG&gt; with response and errorMessage, so failed rows don't fail the job.&lt;/LI&gt;
&lt;LI&gt;Monitor progress in the query profile.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Docs:&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="https://docs.databricks.com/aws/en/large-language-models/ai-query" target="_self"&gt;https://docs.databricks.com/aws/en/large-language-models/ai-query&lt;/A&gt; and&lt;/LI&gt;
&lt;LI&gt;&lt;A href="https://docs.databricks.com/aws/en/large-language-models/ai-functions" target="_self"&gt;https://docs.databricks.com/aws/en/large-language-models/ai-functions&lt;/A&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Good luck&lt;/P&gt;</description>
      <pubDate>Wed, 25 Nov 2026 17:43:42 GMT</pubDate>
      <guid>https://community.databricks.com/t5/generative-ai/ai-query-execution/m-p/177631#M2310</guid>
      <dc:creator>Valeria_Koz_DBX</dc:creator>
      <dc:date>2026-11-25T17:43:42Z</dc:date>
    </item>
    <item>
      <title>Re: ai-query Execution</title>
      <link>https://community.databricks.com/t5/generative-ai/ai-query-execution/m-p/177633#M2311</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/221494"&gt;@Valeria_Koz_DBX&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;could u please elaborate on second level i.e; model serving side&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Nov 2026 17:52:41 GMT</pubDate>
      <guid>https://community.databricks.com/t5/generative-ai/ai-query-execution/m-p/177633#M2311</guid>
      <dc:creator>IM_01</dc:creator>
      <dc:date>2026-11-25T17:52:41Z</dc:date>
    </item>
    <item>
      <title>Re: ai-query Execution</title>
      <link>https://community.databricks.com/t5/generative-ai/ai-query-execution/m-p/177726#M2315</link>
      <description>&lt;P&gt;Sure, happy to. I hope this gives a bit more details and makes it a bit clearer&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;The second level is about where the model inference itself runs, separately from the Spark compute that runs your query.&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;STRONG&gt;Two layers, billed separately&lt;/STRONG&gt;&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Your cluster, serverless compute or Pro/Serverless SQL warehouse runs the query (AI Functions aren't available on Classic SQL warehouses). It reads the rows, builds the prompts and writes the results. Each &lt;SPAN&gt;ai_query&lt;/SPAN&gt;&lt;SPAN&gt; call goes to Model Serving, which runs the LLM inference. For Databricks-hosted models you don't create or size an endpoint. The docs describe them as "provisionless endpoints [that] are fully managed and work best for batch processing."&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;So you see cost in two places: the compute running the query, and the inference.&lt;/STRONG&gt; Per the AI Functions docs, batch inference is recorded in &lt;/SPAN&gt;&lt;SPAN&gt;system.billing.usage&lt;/SPAN&gt;&lt;SPAN&gt; as &lt;/SPAN&gt;&lt;SPAN&gt;MODEL_SERVING&lt;/SPAN&gt;&lt;SPAN&gt; with offering type &lt;/SPAN&gt;&lt;SPAN&gt;BATCH_INFERENCE&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;SELECT usage_date, sku_name, SUM(usage_quantity) AS dbus

FROM system.billing.usage

WHERE billing_origin_product = 'MODEL_SERVING'

  AND product_features.model_serving.offering_type = 'BATCH_INFERENCE'

GROUP BY ALL

ORDER BY usage_date DESC;&lt;/LI-CODE&gt;
&lt;OL start="2"&gt;
&lt;LI&gt;&lt;STRONG&gt; What "managed scaling" means for you&lt;/STRONG&gt;&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&lt;SPAN&gt;According the documentation "AI Functions automatically handle parallelisation, retries, and scaling." &lt;BR /&gt;In practice:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&lt;STRONG&gt;It sends the full dataset in one query.&lt;/STRONG&gt;&lt;SPAN&gt; Manually splitting it into small batches can reduce throughput.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&lt;STRONG&gt;Retries are handled for you.&lt;/STRONG&gt;&lt;SPAN&gt; With &lt;/SPAN&gt;&lt;SPAN&gt;failOnError =&amp;gt; false&lt;/SPAN&gt;&lt;SPAN&gt;, each row returns a struct with &lt;/SPAN&gt;&lt;SPAN&gt;response&lt;/SPAN&gt;&lt;SPAN&gt; and &lt;/SPAN&gt;&lt;SPAN&gt;errorMessage&lt;/SPAN&gt;&lt;SPAN&gt;. Rows that fail on a model endpoint error get a null &lt;/SPAN&gt;&lt;SPAN&gt;response&lt;/SPAN&gt;&lt;SPAN&gt; plus the error, instead of failing the whole job, so you can re-run just those rows later. Other kinds of errors still fail the query.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&lt;STRONG&gt;The docs describe no tuning settings&lt;/STRONG&gt;&lt;SPAN&gt; (concurrency, replicas and so on) for this path. They also note that "performance may not scale linearly from very small workloads to large-scale workloads", so benchmark on a realistic sample, not a few rows.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;OL start="3"&gt;
&lt;LI&gt;&lt;STRONG&gt; Which endpoint you call matters&lt;/STRONG&gt;&lt;/LI&gt;
&lt;/OL&gt;
&lt;UL&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&lt;STRONG&gt;Databricks-hosted models optimized for batch: recommended.&lt;/STRONG&gt;&lt;SPAN&gt; "Databricks optimizes specific models for high-throughput batch workloads." The list is on the ai_query page (for example &lt;/SPAN&gt;&lt;SPAN&gt;system.ai.gpt-5-2&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;system.ai.gemini-3-1-pro&lt;/SPAN&gt;&lt;SPAN&gt;). Other hosted models work but may give lower throughput and longer runs.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&lt;STRONG&gt;Provisioned throughput endpoints:&lt;/STRONG&gt; &lt;SPAN&gt;ai_query&lt;/SPAN&gt;&lt;SPAN&gt; can call them, but "AI Functions does not use the compute provisioned to the endpoint" and "fully manages the scaling used for batch inference". So sizing up a provisioned endpoint won't speed up batch &lt;/SPAN&gt;&lt;SPAN&gt;ai_query&lt;/SPAN&gt;&lt;SPAN&gt;, and the docs recommend Databricks-hosted models instead.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&lt;STRONG&gt;Rate limits:&lt;/STRONG&gt;&lt;SPAN&gt; the published pay-per-token limits (input/output tokens per minute, requests per hour) apply to pay-per-token endpoints. The docs don't say how they apply to batch AI Functions, so don't size a batch job from those numbers.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&lt;STRONG&gt;Custom model endpoints:&lt;/STRONG&gt; &lt;SPAN&gt;ai_query&lt;/SPAN&gt;&lt;SPAN&gt; supports them, and they're billed as their own serving endpoint.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&lt;STRONG&gt;Back to the practical steps&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;OL start="4"&gt;
&lt;LI&gt;&lt;STRONG&gt;Practical checklist&lt;/STRONG&gt;&lt;/LI&gt;
&lt;/OL&gt;
&lt;UL&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&lt;SPAN&gt;Pick a model from the batch-optimized list.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&lt;SPAN&gt;Save the results once with &lt;/SPAN&gt;&lt;SPAN&gt;CREATE OR REPLACE TABLE ... AS SELECT ai_query(...)&lt;/SPAN&gt;&lt;SPAN&gt;, then query that table.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&lt;SPAN&gt;Set &lt;/SPAN&gt;&lt;SPAN&gt;failOnError =&amp;gt; false&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&lt;SPAN&gt;Watch progress in the query profile, and cost in &lt;/SPAN&gt;&lt;SPAN&gt;system.billing.usage&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&lt;SPAN&gt;Docs: &lt;/SPAN&gt;&lt;A href="https://docs.databricks.com/aws/en/large-language-models/ai-functions" target="_blank"&gt;&lt;SPAN&gt;AI Functions&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt; · &lt;/SPAN&gt;&lt;A href="https://docs.databricks.com/aws/en/large-language-models/ai-query" target="_blank"&gt;&lt;SPAN&gt;ai_query&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt; · &lt;/SPAN&gt;&lt;A href="https://docs.databricks.com/aws/en/sql/language-manual/functions/ai_query" target="_blank"&gt;&lt;SPAN&gt;ai_query function reference&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt; · &lt;/SPAN&gt;&lt;A href="https://docs.databricks.com/aws/en/machine-learning/foundation-model-apis/limits" target="_blank"&gt;&lt;SPAN&gt;Foundation Model API limits&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Nov 2026 15:43:06 GMT</pubDate>
      <guid>https://community.databricks.com/t5/generative-ai/ai-query-execution/m-p/177726#M2315</guid>
      <dc:creator>Valeria_Koz_DBX</dc:creator>
      <dc:date>2026-11-26T15:43:06Z</dc:date>
    </item>
  </channel>
</rss>

