A SQLException error occurs when running a Batch Apex job: "First error: SQLException [java.sql.SQLException: ORA-01013: user requested cancel of current operation] thrown but connection was canceled." The batch job is then aborted. This error indicates that a SOQL query within the batch exceeded Salesforce's 2-minute database query timeout and was automatically cancelled. While this error commonly appears in Batch Apex, it can occur in any context where a SOQL query runs longer than 2 minutes, including queries affected by index issues or large data volumes.
The ORA-01013 error occurs when a SOQL query is unselective — meaning it cannot use a database index and must perform a full table scan instead. Full table scans take time proportional to the number of records in the object. The same query may succeed in a sandbox (where total record count including soft-deleted records is lower) but time out in production (where record count is higher). A query is selective when at least one WHERE clause filter returns fewer than 10% of the total records (up to 333,000 records) AND the filter is based on an indexed field.
A query is selective when it meets both criteria:
Standard indexed fields include: lookup fields, master-detail relationship fields, unique fields, external ID fields, and audit fields (such as CreatedDate and LastModifiedDate). Salesforce Support can create custom indexes on specific fields upon request.
Use the Query plan tool in the Developer Console to evaluate whether your SOQL query is index-driven. A "TableScan" operation in the query plan indicates the query is unselective and will scale poorly with data volume. An index-based plan indicates the query is selective.
000385898

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.