SFDO-Community / declarative-lookup-rollup-summaries

Declarative Lookup Rollup Summaries (DLRS) is a community built and maintained Salesforce application that allows you to create cross object roll-ups declaratively - no code! For install instructions and documentation, visit our website https://sfdo-community-sprints.github.io/DLRS-Documentation/
https://sfdo-community-sprints.github.io/DLRS-Documentation/
BSD 3-Clause "New" or "Revised" License
690 stars 235 forks source link

DLRS eating up SOQL 101 Queries Limits #1256

Closed deckblad closed 3 months ago

deckblad commented 1 year ago

When debugging SOQL 101 Query limits, we often find that DLRS is using a vast majority of the query count. Typically 5 to 10 times more than the next most called query. We only have one DLRS trigger per each child object.

I'm aware of the new custom metadata configuration object. If I move all DLRS configurations to the new custom metadata records, will DLRS stop trying to query for the old dlrsLookupRollupSummaryc records? If no, is it possible for DLRS to query all configurations once and cache that statically for the duration of the apex call?

What's my best option here?

Thanks!

aheber commented 1 year ago

@deckblad, I was thinking I had responded to this already but it appears I hadn't. Appologies!

DLRS runs it it's own limits context for SOQL and other limits. This tells me that you have a lot of recursion happening. Could you provide details about the flow of this transaction? Is it looping through the same objects or different objects? Do you have any idea how many times triggers are executing? Scheduled or Realtime rollups?

What version of DLRS are you using?

Depending on the nature of the problem, I'm guessing we could find a way to help mitigate this problem. Don't know specific timelines but I'd love to collect enough information to make sure I understand it then we can figure out what to do about it.

deckblad commented 1 year ago

I'm having a hard time determining where recursion could be occurring. The developer console is... not well built. I'll continue to do my own work to minimize recursion.

My main point here is to suggest that maybe DLRS doesn't need to query for config during every combination of before/after insert/update trigger context. Why can't it load config to a static map? Or, if config is moved completely over to Custom Metadata configurations, having the SOQL query for configurations turned off.

aheber commented 3 months ago

We should have significant improvements for this available in the last few releases. Hopefully it cuts down on DLRS's SOQL usage.