Query Twice Purge Once

There comes a time in every org’s life when space must be made. 

While the thought of deleting possibly millions of records can be terrifying, it may be the only option. 

When this time comes you want to be sure your queries are as accurate as possible. 

I recommend querying for all fields that meet your purge criteria. For example you want to purge all Accounts that are not active, have no account number and have $0 in total opportunities. You could query for that with the following query:

That's perfect to find the records. However when you use a data loader or ETL tool to purge, you are running a query on what could be millions of records with multiple fields. This means that the software first has to identify all records where each of these fields evaluates to TRUE. 

This can best be accomplished with a checkbox. You can simply combine these fields into a formula that evaluates to TRUE. This reduces the time the query takes, thus reduces the time the purge will take. 

This formula will check the box TRUE on the records you intend to purge. You can now run the same query with only one field. The query will run more quickly when purging. 


Running this query is important to verify the number of records equals the number of records in the original query. Query twice, purge once. 

No comments:

Post a Comment