Need a hand tuning your Fabric DW/SQL analytics endpoint?
Which of your queries are bad, and how do you fix them? Ask your warehouse!
Fabric Warehouse now has built-in AI functions you call straight from a query:
- ai_generate_response(prompt, data) → give it a query, ask “as a DBA, what would you change?”, get the answer back as text.https://learn.microsoft.com/sql/t-sql/functions/ai-generate-response-transact-sql?view=fabric
- ai_extract(text, classes…) → pull the tables and predicate columns out of a query as JSON. https://learn.microsoft.com/sql/t-sql/functions/ai-extract-transact-sql?view=fabric
Just point them at queryinsights.exec_requests_history and let the warehouse review its own last 7 days:
select command,
ai_generate_response('As an experienced DBA, review the query text and return what to change in this query to optimize it: ', command) as Issues,
ai_generate_response('As an experienced DBA, rewrite this query to get the optimal version without changing functionality: ', command) as New_Query,
ai_extract(command, 'comma seperated list of columns used in the where predicate') as [Predicates],
ai_extract(command, 'comma seperated list of tables used in query') as [Tables]
FROM (select DISTINCT command from [queryinsights].[exec_requests_history] where submit_time > getdate() - 7) tOne SELECT → issues, a rewrite, predicates and tables for every query.
Get Mark Pryce-Maher’s stories in your inbox
Join Medium for free to get updates from this writer.
To light this up: your admin has enabled the Copilot / Azure OpenAI tenant switch, and you’re in a supported region (some regions need the cross-geo processing setting turned on). Details: https://learn.microsoft.com/fabric/data-warehouse/ai-functions
Thanks to Jovan Popovic for the scripts.
That’s it. Now go let your warehouse tune itself…









