Quote calculation in Salesforce CPQ (managed package) can fail with a "Too Many Query Rows" error or a heap size error when Lookup Price Rules reference large lookup object tables, or when quotes contain many quote lines. The cause is the way Salesforce CPQ queries lookup records.
Salesforce limits the total number of SOQL queries that an org can run per transaction, so Salesforce CPQ cannot query the database separately for each quote line. Instead, Salesforce CPQ Lookup Price Rules combine all lookup criteria into one large SOQL query. The query returns every potential match from the lookup object. Salesforce CPQ then loops over the returned records to find the exact match for each quote line and applies the values in the Salesforce CPQ Price Actions.
The query is assembled as follows:
A price rule sets a quote line field to the value of LOField3 (Lookup Object Field 3), based on QLField1 and QLField2 (Quote Line Field 1 and Quote Line Field 2).
Lookup object records:
Quote lines:
Lookup Queries: QLField1 equals LOField1, and QLField2 equals LOField2.
Price Action: set the quote line field equal to LOField3.
The resulting query is:
SELECT LOField1, LOField2, LOField3 FROM LookupObject WHERE (LOField1 = A OR LOField1 = B) AND (LOField2 = 1 OR LOField2 = 2)
This query selects the three referenced fields and filters on every value that appears across the quote lines. In plain terms, it returns any lookup record whose LOField1 is A or B and whose LOField2 is 1 or 2.
The query returns four lookup records (1, 2, 4, and 5) for only two quote lines, which is twice the number of records needed. Salesforce CPQ then identifies records 1 and 5 as the exact matches.
Adding a third quote line (QLField1 = C | QLField2 = 3) makes the query return all nine lookup records, three times the number needed. The number of Lookup Price Rules, Lookup Queries, quote lines, and lookup table records can therefore have a multiplicative effect on the total query rows returned and on the heap size of the returned list.
The following steps reduce the number of query rows that Salesforce CPQ Lookup Price Rules return and the heap size of the returned list, which prevents the "Too Many Query Rows" and heap size errors during calculation.
Reducing any of these four factors lowers the number of rows returned: Lookup Price Rules, Lookup Queries, quote lines, and lookup table records.
Splitting the lookup object adds one or two SOQL queries to the processing. Each of those queries is more precise, so the overall number of rows returned drops.
If a heap size error continues after the number of query rows is reduced, reduce the amount of data held for each returned record.
000383603

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.