优化查询以检索100天前创建的记录

问题描述 投票:0回答:1

我使用下面的查询来获取100天前创建的记录,然后删除它们。

list exList = [从Exception__c中选择id,其中NOT(CreatedDate = LAST_N_DAYS:100)limit 10000]; system.debug('Exception__c temp fix scList - >'+ exList);删除exList;

这个查询可以进一步优化还是有更好的方法?

list exList = [从Exception__c中选择id,其中NOT(CreatedDate = LAST_N_DAYS:100)limit 10000]; system.debug('Exception__c temp fix scList - >'+ exList);删除exList;

salesforce
1个回答
0
投票

通常,您希望避免在查询中使用否定条件,以使其具有选择性。在你的情况下,我会这样做

Where createddate > last_N_days: 100
© www.soinside.com 2019 - 2024. All rights reserved.