Saturday 20 December 2014

Difference between SOQL and SOSL


SOQL stands for Salesforce Object Query Language
SOSL stands for Salesforce Object Search Language
SOQL can be used in apex triggers, apex classes
SOSL can not be used in apex triggers.

SOQL returns Integer or list of sObject
SOSL returns List of List of sObject

SOQL can be used for DML operations
SOSL can not be used for DML operations

Total no. of SOQL queries issued : 100
Total no. of SOSL queries issued : 20

Total no. of records retrieved by SOQL query : 50,000
Total no. of records retrieved by SOSL query : 2,000


Use SOQL when

1. you know in which objects or fields the data resides.
2. you want to retrieve data from single object or multiple objects that are related to one another.
3. you want to count number of records meeting the criteria in query.
4. you want to sort the result.
you want to retrieve data from number, date or checkbox fields.

Use SOSL when

1. you don't know in which object or field the data resides.
2. you want to retrieve data from single or multiple objects that may or may not relate to each other.

No comments:

Post a Comment