Loading
Salesforce Help 사이트 “Help Agent powered by Fin” 도입 안내더 많이 읽기
Tableau 고객 대상: Tableau를 이용하는 고객이 Help 사이트에서 사례(케이스)를 등록할 수 없는 경우의 대체 수단더 많이 읽기
Slack 관련 문의처가 Salesforce Help로 통합 및 변경됩니다.더 많이 읽기

SQLException 'User requested cancel of current operation'

게시 일자: Jun 15, 2026
상세 설명

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.

솔루션

Root Cause — Query Selectivity

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.

What Makes a Query Selective?

A query is selective when it meets both criteria:

  1. At least one WHERE clause filter returns fewer than 10% of total records (up to 333,000 records).
  2. The filter is applied to an indexed field.

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.

How to Diagnose Query Selectivity

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.

Resolution Options

  1. Add a selective WHERE clause filter: Add a filter on an indexed field (such as CreatedDate or a lookup field) to make the query index-driven and reduce execution time.
  2. Request a custom index: Open a case with Salesforce Support to request a custom index on the field(s) most frequently used in your WHERE clause.
  3. Refactor the Batch Apex start() method: Update the QueryLocator in the start() method to use a more selective filter that reduces the result set and ensures index use.



Knowledge 기사 번호

000385898

 
로드 중
Salesforce Help | Article