We're looking to track where certain records were created (e.g. from a User within Salesforce, from our website etc...). We're wondering what is the best and least CPU intensive way of querying these records as this could be an object with a large amount of records.

We're considering two options: checkboxes (ticked if created from Salesforce, another ticked if created from the website) or a picklist. Picklist seems to make the most sense given the record could only ever be created from location but we don't want to rule out checkboxes either if it helps performance.

We're expecting that it's more CPU intensive to compare a Strings then looking for true or false (e.g. SELECT Id FROM Object__c WHERE Created_Salesforce = true vs. SELECT Id FROM Object__c WHERE Location_Created__c= 'Salesforce'). But it may be more CPU intensive to find the specific checkbox in a query.

Put simply:

Is querying checkboxes more efficient or is querying picklists more efficient?


How might we find out which method yields better performance?

  • I might have not understood the question but Querying is not CPU intensive (as for govenror limits) because querying is not counted in CPU limits. Are you referring to performing some comparison operation in apex code after querying or the wait time while the data is being queried from DB. – manjit5190 Oct 14 '15 at 13:53
  • Effectively I'm curious to know if it's faster for Salesforce to find potentially multiple checkboxes, then compare a simple true or false as to where the record was created (theoretically there could be 3 or 4 of these checkboxes where only one should ever be true), or find the one picklist value but then spend the time comparing the Strings? – Dan Jones Oct 14 '15 at 14:18

From a user experience perspective, the primary reason you would use a picklist (or radio buttons, in other UIs) when it's a binary would be when the consequences for checked versus unchecked choices would be ambiguous. For example, if it's an option for enabling something and it's not clear what will happen if you don't enable it.

For the case of a simple yes/no, a checkbox is usually fine, and it's a little easier to deal with in formulas referencing the checkbox since you can just use IF(MyField__c, true case, false case) as opposed to IF( ISPICKVAL(MyField__c, "Yes"), true case, false case). But if you think you might add other options in future, you might want to go with the picklist.

  • Thanks. Great point. This question was posed by one of my colleagues and the UX perspective is what I've suggested as it happens as I said in my question, it seems to make the most sense in this instance. But I'm quite curious to know as to any differences in performance. – Dan Jones Oct 14 '15 at 14:14
  • it would be very Minute. – Venky Oct 14 '15 at 14:21
  • The more I think about it the less sense it makes to use Checkboxes in this instance and to use a picklist as per my initial instinct. Irrespective of performance, picklists seem to be the right approach. – Dan Jones Oct 14 '15 at 15:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.