[SERVER-11803] $where clause invoked twice Created: 20/Nov/13 Updated: 10/Dec/14 Resolved: 21/Nov/13 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Querying |
| Affects Version/s: | 2.5.4 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | A. Jesse Jiryu Davis | Assignee: | hari.khalsa@10gen.com |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Backwards Compatibility: | Fully Compatible | ||||||||||||
| Operating System: | ALL | ||||||||||||
| Steps To Reproduce: |
This logs:
If you remove the _id and foo filters from the query, then the JS function only runs once. |
||||||||||||
| Participants: |
| Description |
|
If a $where clause is combined with other filters in a query, the Javascript function in the $where clause is invoked twice. |
| Comments |
| Comment by hari.khalsa@10gen.com [ 21/Nov/13 ] | |||||
|
If we're running two queries in order to compare them and select the best, I think this works as intended. | |||||
| Comment by A. Jesse Jiryu Davis [ 21/Nov/13 ] | |||||
|
Looks like newRunQuery tries two plans, thus invoking the JS function twice. This is surprising for driver tests that need a query to be slow, and expected a query like this:
... always to take about one second, not two. When a $where clause is used for its intended purpose, rather than for a side effect, this is less of an issue. | |||||
| Comment by A. Jesse Jiryu Davis [ 20/Nov/13 ] | |||||
|
Bad behavior starts at this commit:
|