Comparision between SOSL and SOQL in Salesforce?

0 votes
Anonymous User asked 02-Feb-2018 in SalesForce by Anonymous User

Comparision between SOSL and SOQL in Salesforce?

1 Answer

0 votes
Anonymous User answered 02-Feb-2018 by Anonymous User

I have listed some of the comparisons between SOQL and SOSL: 

Using SOQL, we search against the org’s database. Using SOSL, we don’t know in which object or field the data resides. 
The results after searching the data include matches for the exact search string.  We can find object or field in the most efficient and fastest way possible.
Using SOQL, we know in which objects or fields the data resides. We can fetch data for a specific term which we know exists within a field because SOSL can tokenize multiple terms within a field and build a search index for this.
Using SOQL, we can search at a time only one object. SOSL query can search many objects at a time.
Using SOQL, we can fetch all fields with any type of datatypes. Using SOSL, we can search the only datatype of text, phone, and email type records.
SOQL is used in Triggers and classes. In SOSL, classes are used but Triggers are not in use.
SOQL query performs DML operations on query results. Using SOSL query, DML operations are not allowed.  
We can fetch data from single or multiple objects which are related to one another. SOSL searches are faster and can return more relevant results.
We can count the number of records that meet specified criteria. Depending on the search object, SOSL searches also take advantage of the advanced features of the search index.
We can get sorted results as part of the query. We can fetch multiple objects and fields that might or might not be related to one another comfortably.
We can fetch data from number, date, or checkbox fields. We can fetch data for a particular division and find it in the most efficient way possible in an org using the divisions' feature.