# What are the key differences between SOQL and SOSL, and when do you choose one over the other?

**Topic:** Soql · **Difficulty:** Easy · **Asked at:** Accenture, Cognizant, Capgemini · **Tags:** soql, sosl, fundamentals

Read it on the site: https://www.forcechallenges.com/interview-questions/what-are-the-key-differences-between-soql-and-sosl-and-when-do-you-choose-one-over-the-other

## Answer

| | SOQL | SOSL |
|---|---|---|
| Purpose | Query records of one object (plus related) | Text search across many objects and fields |
| Returns | List of sObjects | List of lists of sObjects |
| Search | Field-based WHERE filters | Full-text search index, word matching |
| Limits | 100 queries, 50,000 rows | 20 SOSL queries, 2,000 rows each |
| Use when | You know the object and need filtered/related data, aggregates | You don't know which object/field holds the text, or need fuzzy text search |

```apex
List<List<SObject>> r = [FIND 'Acme*' IN ALL FIELDS RETURNING Account(Id, Name), Contact(Id, Name)];
```

---
Source: ForceChallenges · last updated 2026-10-21
