[DOCS-382] Explain in $or query operation documentation when using $in might be optimal Created: 07/Aug/12 Updated: 30/Oct/23 Resolved: 27/Sep/12 |
|
| Status: | Closed |
| Project: | Documentation |
| Component/s: | manual |
| Affects Version/s: | None |
| Fix Version/s: | Server_Docs_20231030 |
| Type: | Improvement | Priority: | Minor - P4 |
| Reporter: | Daniel Gottlieb (Inactive) | Assignee: | Kay Kim (Inactive) |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Participants: | |||||||||
| Days since reply: | 11 years, 22 weeks, 6 days ago | ||||||||
| Description |
|
This is being created due to the linked ticket. I feel the problem is common (and simple) enough to warrant a small docs update. People will sometimes want to literally translate the SQL clause:
into
instead of using the `$in` operator. Furthermore they'll follow the same logic to translate:
into
because they know queries are (generally implemented as) a map and there can't be two distinct values for the same key. Using the `$in` operator really shines in this case to simplify the query to:
Specifically speaking, the `$in` operator should be used as a special case of `$or` where the key being checked is always the same. Speaking more generally, there may be enough oddities trying to translate directly from SQL to Mongo's query language that warrants a quick page of tips for those with an existing strong SQL querying experience. |
| Comments |
| Comment by auto [ 13/Sep/12 ] |
|
Author: {u'date': u'2012-09-13T07:21:36-07:00', u'email': u'kay.kim@10gen.com', u'name': u'kay'}Message: |
| Comment by auto [ 13/Sep/12 ] |
|
Author: {u'date': u'2012-09-10T19:39:57-07:00', u'email': u'kay.kim@10gen.com', u'name': u'kay'}Message: |
| Comment by auto [ 13/Sep/12 ] |
|
Author: {u'date': u'2012-09-10T14:09:56-07:00', u'email': u'kay.kim@10gen.com', u'name': u'kay'}Message: |
| Comment by Daniel Gottlieb (Inactive) [ 07/Aug/12 ] |
|
Maybe it's really a duplicated case, but |