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.
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?