This GitHub Action automates the measurement of database performance in Salesforce by analyzing Query Plans. It tracks the results of Query Plan parameters on ListViews, Reports, and Queries from input files.
Utilizes REST communication with Salesforce CLI on Query Explain endpoint
curl https://MyDomainName.my.salesforce.com/services/data/v63.0/query/?explain= SELECT+Name+FROM+Merchandise__c+WHERE+CreatedDate+=+TODAY+AND+Price__c+>+10.0
- Automated Query Plan Analysis: Extracts and evaluates Query Plans for List Views, Reports, and SOQL queries.
- Continuous Monitoring: Runs on each pull request to identify database inefficiencies early.
- Historical Comparison: Retains previous Query Plan results as JSONs, storing them in Action's Artifacts.
- Query Detection in Apex & Flows: Notifies about potential database queries introduced in Apex classes and Flow metadata.
flowchart TD
A((Start)) -->C
C{{ Explain elements of...}}
C -->|ListViews or Reports| D[**SF REST Query** <br /> those viewed or ran<br /> last month]
C -->|SOQLs| E[Get Queries from <br /> prepared file]
D-->F[Download Artifacts from previous run]
E-->F
F-->G([On each element...])
G-->H[Run **SF REST Query Explain** <br />⟲]
H-->I[Append JSON result to Artifact<br />⟲]
I-->J([...until last...])
J-->|Loop|G
J --> K[Upload updated Artifact]
K-->P((End))
- Trigger on Pull Request: By default, the workflow executes when a PR is opened or updated.
- Retrieve List Views and Reports: Using REST API, retrieves list of List Views and Reports that were used last month, to pass them into Explain endpoint.
- Query Plan Extraction:
- Fetches Query Plans for List Views and Reports retrieved from Salesforce automatically.
- Reads predefined SOQL queries from CSV files, that should be filled manually.
- Performance Tracking: Captures execution plans, indexes used, and cost estimates.
- Artifacts Storage: Saves Query Plan results as artifacts for tracking changes over time.
- Commenting on PRs:
- Detects new queries in Apex classes, whenever
SELECTorQUERYare found in.clsfiles. - Identifies database interactions in Salesforce Flows.
- Detects new queries in Apex classes, whenever
- Get Salesforce Access Token for SF CLI
- Configure GitHub Secrets:
SFDX_AUTH_URL: Authentication token for Salesforce.
- Add Queries to CSV Files:
- Place SOQL queries in
./queryPlanExplains/soqlsToExplain.csvand./queryPlanExplains/queriesFromFlowsToExplain.csv. Both are processed identically, split is for organization purposes.
- Place SOQL queries in
You are welcome to put some work into it.
This project is licensed under the MIT License.