I have seen some strange issues in a Azure SQL DB (Serverless) recently. (General Purpose - Serverless: Gen5, 1 vCore)
Tables with approx 120000 rows have aggregate queries taking minutes to complete if more than 2 grouping columns are used.
Example:
select sum(amount), company_key, account_key from #myTable group by company_key, account_key
This will complete on a few seconds (returning a result set on approx 10000 rows).
But adding a third "group by" column will cripple the execution:
select sum(amount), company_key, account_key, cost_center_key from #myTable group by company_key, account_key , cost_center_key
will take a few minutes! (Yes, it will return a larger resultset - but no extremes? about 60000 records)
This behaviour is consistent when using MERGE, Window functions and index creation.
The behaviour is similar using either "normal" tables or temp tables. And index creation is also very slow.
I have never seen similar behaviour where a small change in the SQL have such an impact on performance! And on such small datasets...
The code was running without issues for a couple of weeks when this behaviour suddenly occurred in mid August. (No code change and no increase in data size)
Any tips or similar experiences? Thanks!