Universal Containersは、カスタムLightningページを使用して、ステップバイステップのウィザードで取引先を検索できるメカニズムを提供しています。ウィザードのステップの1つでは、ユーザーがテキスト項目「ERP_Number__c」にテキストを入力し、そのテキストをクエリで使用して一致する取引先を検索します。 ジャワ erpNumber = erpNumber + '%'; List<Account> アカウント = [SELECT Id, Name FROM Account WHERE ERP_Number__c LIKE : erp番号]; 開発者が「SOQLクエリの選択性が不十分です」という例外を受け取りました。この問題を解決するには、どのような手順を踏む必要がありますか?
正解:C
The "SOQL query not selective enough" error occurs when a query on an object with a large volume of records (typically over 200,000) does not use a filtered index to narrow down the result set effectively. In Sales1force,2 the query optimizer must be able to use an index to scan a small enough percentage of the total records to maintain performance. When a query filters on a non-indexed field, the system is forced to perform a full table scan, which triggers this exception to prevent performance degradation. To resolve this, the developer must ensure that the field used in the WHERE clause is indexed. Marking a custom field as an "External ID" or "Unique" automatically creates a custom index on that field. By marking ERP_Number__c as an External ID, the platform generates a underlying database index, allowing the query optimizer to quickly locate matching records without scanning the entire table. While the LIKE operator with a trailing wildcard (e.g., 'Text%') can utilize an index, it will only be considered "selective" if the filter narrow the results below the platform's selectivity thresholds (typically 10% of the first million records). Making the field an External ID is the standard programmatic solution to provide the necessary indexing for selectivity. Option A is incorrect because moving a non-selective query to an asynchronous process does not change the fact that it is non-selective; it will still fail.