You need to sign in to do that
Don't have an account?
Jaffer Ali.
one million record processing in apex
Hey guys,
I got a critical case, as present below.
Problem:
In one of my objects there are five long text area fields. I want to perform search on those fields and update all records , once it is done. My expected result set contains 600 thousand records.
My Solution:
I created a btach class to perform this task, as Like statement is not allowed for long text area so I am scanning all records and then using "contains" function in apex to see if it is matched.Right now, it is taking 45 minutes to complete that job for 100 thousand records which is really too long.
Is there any other way I can make this process faster. Need suggestions.
I got a critical case, as present below.
Problem:
In one of my objects there are five long text area fields. I want to perform search on those fields and update all records , once it is done. My expected result set contains 600 thousand records.
My Solution:
I created a btach class to perform this task, as Like statement is not allowed for long text area so I am scanning all records and then using "contains" function in apex to see if it is matched.Right now, it is taking 45 minutes to complete that job for 100 thousand records which is really too long.
Is there any other way I can make this process faster. Need suggestions.
Instead of using CONTAINS try using "Equal to", this is because the CONTAINS operator requires a full scan of the index and takes more time. Please refer section "More Efficient SOQL Queries" in following help document in order to optimize your query:
https://www.salesforce.com/us/developer/docs/apexcode/Content/langCon_apex_SOQL_VLSQ.htm
If you can not avoid use of "Contains" filter then try optimizing the query by other means provided in the above document. Query has to be optimized to make it run fast.
Can you share you query for further suggestions?