1

Do Lightning Web Components operate in their own transaction when it comes to SOQL query limits? For example, if I have a Lightning Page with several LWCs, can I focus on each LWC as a single entity with it's own transaction limits or do I need to be aware of the number of SOQL calls from each LWC?

Also a more general question in regards to best practices. If I need to summarize data from both the entire set of instances of an object, and a subset(s) of the instances, is it better to do a single SOQL query and iterate over the instances to calculate the summary values? Or is it better to issue two (or more) separate SOQL queries? I realize the answer here is probably contextual, but I'm never come across any guidelines from Salesforce.

3

When LWC initially came out, several operations queued at once would share governor limits. This changed in Winter '20. Each call to the server now gets the full governor limits, even when using the boxcar feature that groups calls together. See this question for more details.

As far as using one query or two? Use one query and post-process in JavaScript. The database is more efficient than Apex for aggregating data, but JavaScript will save you time on the server, and will ultimately be faster.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.