Sitemap
Mark Pryce-Maher

Mark Pryce-Maher

I'm a Senior Program Manager at Microsoft, I work on the Data warehouse in Fabric, it includes Mirroring, MDSync and other stuff.

Need a hand tuning your Fabric DW/SQL analytics endpoint?

2 min readAug 21, 2026

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:

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) t

One 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…

Press enter or click to view image in full size

--

--

Mark Pryce-Maher
Mark Pryce-Maher

Written by Mark Pryce-Maher

I'm a Senior Program Manager at Microsoft, I work on the Data warehouse in Fabric, it includes Mirroring, MDSync and other stuff.