If you want to check if there is record of ProcessInstance exists in the system or not, please suggest which one of the following approch is faster and best practice to use ?
Approch 1 - Query Object with Id field and check list has returned any rows or not.
Select TargetObjectId, Status From ProcessInstance where TargetObjectId='006g0000003AitI' and Status='Pending' limit 1
Approch 2 - Use Count SOQL to check if any records exists in the system or not as follows -
Select count() From ProcessInstance where TargetObjectId='006g0000003AitI' and Status='Pending'
I tested it in terms of timing there is no significant difference between both.