Reducing use of SOQL in synchronous context #303
Replies: 1 comment 4 replies
-
Hi @LawrenceLoz, this is some incredible feedback, thanks for taking the time to share your findings & thoughts! Currently, the code runs 3-5 queries synchronously ( I think there are a couple of changes that could be combined to improve the query usage:
Let me know your thoughts on these possible changes! And that's awesome to hear that you might discuss Nebula Logger at London's Calling! I'd absolutely love to hear more about what you'll be covering - feel free to message me on LinkedIn if you'd like to discuss it outside of GitHub. Thanks again for your feedback! |
Beta Was this translation helpful? Give feedback.
-
Hi there,
Firstly big kudos to author/authors and contributors on this project - a really rich and intuitive set of features and some great configuration flexibility.
Running a few experiments and looking at debug logs, I've noticed that when the Logger object class is called several queries are run within the transaction which contribute to the limit of 100 SOQL statements - in my tests this is 4 queries and I think would be 5 for logs being made for community users. Whilst this isn't an especially high, in an ideal world given how widely a logging framework should be used it would be great to reduce the utilisation and improve synchronous performance where possible.
There are a couple of areas resulting in queries being run, and I wonder whether it's viable to refactor to avoid these:
LogEntryEventHandler().executeBeforeInsert(logEntryEvents);
As part of this, TAG_ASSIGNMENT_RULES variable is set from the results of a CMDT query, which includes flitering on SObjectField__r.QualifiedApiName (the bit which makes the CMDT query contribute to limits like a normal SOQL object query). This variable isn't used until after PEs are created so feels like this should be called only at that stageI'm happy to create issues and help out with PRs suggesting changes for some or all of these areas if you agree there's a better approach? Or let me know if I'm missing something about how any of these can be avoided today?
Also a heads up I'm hoping to touch on Nebula Logger as part of a talk I'm co-presenting at London's Calling soon (https://www.londonscalling.net/sessions/session-apex-frameworks-for-architects/). Let me know if you'd like more insight into how this would be included (or if for any reason you'd prefer Nebula Logger not to be included!)
Again, thanks for the great work - I've developed a similarly architected logging framework myself and familiar with many of the challenges you've addressed really well here!
Beta Was this translation helpful? Give feedback.
All reactions