Find SOQL 101 risks with SOQL Risk Intelligence
Detect SOQL anti-patterns, duplicate queries and transaction-level query counts that risk the 100-query governor limit, and get AI remediation advice.
Overview
SOQL Risk Intelligence helps you find the code that pushes transactions toward the Salesforce limit of 100 SOQL queries — the "SOQL 101" error. The page covers anti-pattern detection, transaction estimation and AI remediation in one place.
The old Governor Risk link (/governor-risk) now opens this page.
Before you start
- The org must be synced and then indexed. Index it from Apex Flow Analyzer (Index Org) or from Sync Center, or use Index Org for SOQL on this page.
- AI Risk Insights needs an AI provider configured in Settings → AI Providers.
Steps
- Open SOQL Risk Intelligence under Code & Performance Analysis.
- Pick the org.
- Leave the Test Classes toggle off unless you want test code included. Tests are excluded by default.
- Read the Overview tab for the headline risk picture.
- Open Anti-Patterns to see queries in loops and similar risky constructs.
- Open Duplicate Queries to see the same query issued more than once in a transaction. Click Export Word Report to share it.
- Open Data Access Intelligence for Object Analysis, Component Patterns, Within-Class Cache (with ⚡ AI Analyze) and the Access Heat Map.
- Use SOQL Inventory to browse every query found, and Transaction Analyzer to estimate query counts per transaction.
- On AI Risk Insights, click Run AI Analysis. It takes about 30–60 seconds and the result is saved.
- After code changes and a re-sync, click Refresh analysis.
Example
Priya, a release manager, opens acme-prod before a data migration. Transaction Analyzer shows that an Opportunity update path issues an estimated 70 queries for a single record. Duplicate Queries shows the same Account lookup issued from three different classes in that path. She exports the Word report and creates ticket ACME-142 to add a shared selector that caches the Account lookup.
FAQs
Why are test classes excluded by default?
Test classes set up their own data and never run against a production batch, so including them inflates the numbers. Turn on Test Classes when you want to review test code specifically.
Is this the same as Code Analyzer?
No. Code Analyzer runs a tunable rule catalog across Apex, triggers and Flows. SOQL Risk Intelligence focuses on query volume, duplication and data access patterns across a transaction.
Does Run AI Analysis send my code to an AI provider?
It uses the AI providers configured for your workspace. See Who pays for AI generation for details.
Troubleshooting
"No SOQL Data Found"
The org has not been indexed. The page tells you to go to Apex Flow Analyzer, select your org, and click Index Org. You can also click Index Org for SOQL here.
"Failed to load governor data. Index the org first."
Indexing has not completed for this org, or it failed. Run an index, wait for it to finish, then click Refresh analysis.
AI analysis does nothing or fails
Check that an AI provider is configured in Settings → AI Providers. See Fix "AI provider not configured".
Related articles
Was this article helpful?
Related articles
- Index an orgBuild or rebuild an org's analysis index from its last sync so Code Intelligence, SOQL Risk, Query Amplification and other analysis pages show current results.
- Measure query amplification in trigger chainsSee how many SOQL queries each transaction issues compared with the data it actually needs, find the worst trigger chains and objects, and save snapshots to track progress.
- Trace execution paths with Apex Flow AnalyzerIndex an org's Apex, triggers and Flows, then trace what runs when a record changes — including async boundaries, per-step governor risk and duplicate queries — in plain language or by browsing.
- Configure AI providersAdd AI provider keys, set the fallback order and verify that AI works for your workspace, using the guided setup in Settings, AI Providers.
- Analysis pages show no dataIf Code Intelligence, SOQL Risk, Query Amplification or other analysis pages are empty, the org usually needs a sync, an index, or a full resync. Here's how to tell which.