I have been trying to chase down some performance issues and came across something really odd. I was able to reproduce it by making a new baq, and adding only PartAlloc to it, then generating the execution plan. Why does the execution plan show this when I have no table or subquery criteria in my baq? Its extremely inefficient. Even if I add a criteria for company = current company it just appends that on, it doesn’t replace this. Has anyone seen this before or have any idea how to make it stop? Cloud 2025.1.12
;from [Erp].[PartAlloc]
where ( [PartAlloc].[Company] is null or [PartAlloc].[Company] = N'' or [PartAlloc].[Company] = @CurrentCompany )"
All companies just means you can run the baq from any company. It still only ever gives you results for the current company context so those results don’t surprise me.
Hmm. I would expect similar additions for site security and territory security.
But why test for blank or null company? Might this be a holdover from older, upgraded systems from the V6 days? I don’t see any PartAlloc records missing these fields but I haven’t checked all tables either…
Blank company can be in some tables, especially old ones, meaning all companies data.
Company is null may happen in left outer joins, when second table does not have such row.
Why not remove records with blank company values during conversion? There is no valid reason for a record in PartAlloc to not have a company value? Vs. hindering performance of every partalloc baq forever?
Why. Its redundant with company = current company and its hindering the performance of the baq.
I feel I am caught in a catch 22 here. I complain about cloud performance. Cloud ops blames my baq. When I run the execution plan, the items with the biggest impact are:
Missing indexes (can’t do anything about this in cloud)
Outdated statistics (can’t do anything about this in cloud)
Antipattern in criteria (apparently can’t do anything about this in cloud either)
So . . . cloud ops won’t address performance impact of baqs even though the tools are not provided to improve the performance of the baq in the cloud.
Company is always indexed, in most cases it is part of clustered index as well. Also when you move on with additional tables and filtering then maybe SQL server will be able to find even better order to filter data.
But if your goal to get only the data from this one table, then there is what you can have in BAQ.
If cloud team complains about this query exactly, then maybe you return too many row and you should not do it?