SOSL vs. SOQL

Curiosity got the best of me, and I decided to run a rudimentary benchmark against a small data set, using both SOSL and SOQL for search. Results below.

First, to run the benchmark, I fired up a fresh dev org and loaded as many records as I could. With a standard dev org and the import schema below, that meant 14,100 account records.

In order to have something to search against, I uploaded just a single field; an incrementing name field.

Testing this in the system log provided the following results.

SOSL Test
List searchList = [find '%99%' in name fields returning Account(Name)];

SOQL Test
List searchList = [select Id from Account where Name like '%99%'];

Findings/Case for SOSL
SOSL came in at 32ms, while SOQL was a full 22% slower at 39ms. Obviously, this was a small data set, but gives you a sense for how SOSL may scale at larger volumes.

Additionally, SOSL has the ability to easy search across all fields, and include multiple objects in the data set, while SOQL would require multiple queries or an object relationship to accomplish the same thing.

SOQL is going to be the stronger general use query tool, but for straight-up search it’s hard to ignore the benefits of SOSL. That is what it was designed for, after all.

What do you think? Thoughts/experiences with SOSL vs. SOQL? Was this a fair test?

Quick Find Keyboard Shortcut

Whether you make a hobby out of reducing mouse clicks to the bare minimum, or just find yourself clicking the Quick Find field or Setup link in Salesforce several times a day, you should get some value out of this browser script.

Download here: http://userscripts.org/scripts/show/123715

It binds a keyboard shortcut (⌘+Shift+F on Mac, Ctrl+Shift+F on Windows/Mac) to both the Quick Find field and setup menu, for easy access. How does it work? Pretty simple:

  • If you’re on a non-setup page, the shortcut will take you to the setup menu landing page.
  • If you’re in the setup menu, the shortcut will apply field focus to the Quick Find field.

Simple, but it saves me a couple of seconds hundreds of times a day. Check it out, and let me know what you think!