microsoft / Analysis-Services

Git repo for Analysis Services samples and community projects
MIT License
607 stars 416 forks source link

Add rule for excessive number of measures in model #236

Open DBojsen opened 1 year ago

DBojsen commented 1 year ago

I believe a model should not have more than a few hundred measures. More are typically a sign of poor model design or not using modern features such as calculation groups. This rule highlights if a model has more than 500 measures. If there is a good reason for this, if prompts the user to disable all BPA rules that iterate over the Model.AllMeasures collection as we have seen users TE becoming unresponsive if using these rules with a really big quantity measures.

@m-kovalsky

DBojsen commented 1 year ago

@microsoft-github-policy-service agree company="Tabular Editor ApS"

otykier commented 1 year ago

Case in point: https://github.com/TabularEditor/TabularEditor/issues/1148#issuecomment-1777267956

m-kovalsky commented 1 year ago

Thanks David, I completely agree with this and have experienced this myself (which is why I generally recommend not having the background BPA scan enabled). Would you point me to where Tabular Editor notifies the user to disable all BPA rules which use the Model.AllMeasures?

DBojsen commented 1 year ago

Would you point me to where Tabular Editor notifies the user to disable all BPA rules which use the Model.AllMeasures?

It's just in the rule description - we don't have a mechanism for prompting or the likes from a BPA rule. Perhaps my PR description should have mentioned that.

marcosqlbi commented 1 year ago

I would say that 500 could be a too low limit. While it is true that there is a performance penalty with thousands of measures in the model, it is also true that calculation groups for time intelligence are not the best practice from a performance standpoint. A limit at 1500 would better IMHO. If you use Bravo for Power BI it's easy to get many measures generated automatically. 500 seems a low number IMHO.

m-kovalsky commented 1 year ago

Ah I see, thanks David. Yes, I had a feeling that the number chosen here (500, 1500 etc.) would be contentious. The primary part of the problem is rules which use measure x measure comparison (i.e. [DAX Expressions] No two measures should have the same definition). Then it's the square of the number of measures in the model (1,000 measures -> 1,000,000 checks).

DBojsen commented 1 year ago

@m-kovalsky & @marcosqlbi

I don't feel strongly if the limit should be 500, 1500 or something else - but I feel it would be a good check to add to the list. I can change the limit, if you like. To 1500 ?

m-kovalsky commented 1 year ago

It's fine with me. Also remember that folks can always modify this number for their own use case if they so desire.

DBojsen commented 1 year ago

Perfect, I updated the rule definition