AsyncApexJob に対するクエリでは、以下のメッセージを受け取る場合があります:
System.QueryException: Non-selective query against large object type (more than 100,000 rows). Consider an indexed filter or contact Salesforce about custom indexing.
AsyncApexJob レコードの数が増加すると、このオブジェクトに対するSOQLクエリは非選択的クエリエラー(non-selective query error)を発生させます。Salesforce は完了済みの AsyncApexJob レコードを7日後に自動的に削除しますが、トランザクション量の多い組織では、この自動クリーンアップだけではレコード数を減らすのに不十分な場合があります。
デフォルトの動作: 7 日後の自動削除
Salesforceは、実行から 7 日経過した完了済みの AsyncApexJob レコードを自動的に削除します。ほとんどの組織では、これでレコードの過剰な蓄積を防ぐことができます。しかし、スケジュール済み Apex やバッチ Apex ジョブの実行量が非常に多い組織では、自動削除によるクリーンアップが追いつかず、レコードが蓄積してしまうことがあります。
AsyncApexJob レコードを手動で削除する方法(API バージョン 65 以前)
purgeOldAsyncJobs(Date) メソッドを使用すると、指定した日付より前の CreatedDate(作成日)を持つ、完了済みのすべての非同期ジョブを削除できます。このメソッドは、開発者コンソールの「Execute Anonymous(匿名の実行)」から、またはスケジュール済みApexクラスから呼び出します。
API バージョン 66.0 以降では、 purgeOldAsyncJobs(Date, numOfJobs) を使用して、1 回の処理で削除する最も古い完了済み非同期ジョブの最大件数を指定できます。上限件数を設定することで、1 回のトランザクションで Apex ガバナ制限を回避しつつ大量のレコードを削除したい場合に、段階的な削除が可能になります。
000383655

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.