<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 04:45:57 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>MongoDB Jira</title>
    <link>https://jira.mongodb.org</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>9.7.1</version>
        <build-number>970001</build-number>
        <build-date>13-04-2023</build-date>
    </build-info>


<item>
            <title>[SERVER-37423] query does not use same execution plan w/wo explain(executionStats)</title>
                <link>https://jira.mongodb.org/browse/SERVER-37423</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;Hello,&lt;/p&gt;

&lt;p&gt;I open this ticket adviced by Renato.&lt;/p&gt;

&lt;p&gt;We have an slow query (find+sort) that takes 5 minutes. The collection has 1.2million documents:&lt;/p&gt;

&lt;p&gt;&lt;tt&gt;db.PassengerNameRecord.find({&#160;&#160;&#160;&#160; &quot;value.airSegments.serviceProviderCode&quot; : &quot;AC4&quot;,&#160;&#160;&#160;&#160; &quot;value.airSegments.identifier.code&quot; : &quot;123&quot;,&#160;&#160;&#160;&#160; &quot;value.airSegments.start.locationCode&quot; : &quot;CDG&quot;,&#160;&#160;&#160;&#160; &quot;value.airSegments.end.locationCode&quot; : &quot;YVR&quot;,&#160;&#160;&#160;&#160; &quot;value.airSegments.start.date&quot; : &quot;2018-09-25&quot;,&#160;&#160;&#160;&#160; &quot;value.airSegments.identifier.suffix&quot; : &quot;A&quot; })&lt;b&gt;.sort({fid:1})&lt;/b&gt;&lt;/tt&gt;&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;The same query with an explanation plan takes less than 1 second:&lt;/p&gt;

&lt;p&gt;&lt;tt&gt;db.PassengerNameRecord.find({&#160;&#160;&#160;&#160; &quot;value.airSegments.serviceProviderCode&quot; : &quot;AC4&quot;,&#160;&#160;&#160;&#160; &quot;value.airSegments.identifier.code&quot; : &quot;123&quot;,&#160;&#160;&#160;&#160; &quot;value.airSegments.start.locationCode&quot; : &quot;CDG&quot;,&#160;&#160;&#160;&#160; &quot;value.airSegments.end.locationCode&quot; : &quot;YVR&quot;,&#160;&#160;&#160;&#160; &quot;value.airSegments.start.date&quot; : &quot;2018-09-25&quot;,&#160;&#160;&#160;&#160; &quot;value.airSegments.identifier.suffix&quot; : &quot;A&quot; })&lt;b&gt;.sort({fid:1}).explain(&quot;executionStats&quot;)&lt;/b&gt;&lt;/tt&gt;&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;Seems the query does not execute in the same way when we use or not the &lt;b&gt;explain&lt;/b&gt;.&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;&lt;font color=&quot;#212121&quot;&gt;This is the output logged on the console from mongoD:&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;font color=&quot;#212121&quot;&gt;2018-10-02T08:41:57.913+0000 I COMMAND &lt;span class=&quot;error&quot;&gt;&amp;#91;conn352677&amp;#93;&lt;/span&gt; command sampledb.PassengerNameRecord appName: &quot;MongoDB Shell&quot; command: find { find: &quot;PassengerNameRecord&quot;, filter: { value.airSegments.serviceProviderCode: &quot;AC4&quot;, value.airSegments.identifier.code: &quot;123&quot;, value.airSegments.start.locationCode: &quot;CDG&quot;, value.airSegments.end.locationCode: &quot;YVR&quot;, value.airSegments.start.date: &quot;2018-09-25&quot;, value.airSegments.identifier.suffix: &quot;A&quot; }, sort: { fid: 1.0 }, $db: &quot;sampledb&quot; } planSummary: IXSCAN { fid: 1 } keysExamined:1284240 docsExamined:1284240 cursorExhausted:1 numYields:13909 nreturned:0 reslen:101 locks:{ Global: { acquireCount: { r: 27820 } }, Database: { acquireCount: { r: 13910 } }, Collection: { acquireCount: { r: 13910 } } } protocol:op_msg 225041ms&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;&lt;font color=&quot;#212121&quot;&gt;And here the output of the explain plan with the sort predicate:&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;font color=&quot;#212121&quot;&gt;&amp;gt; db.PassengerNameRecord.find({ &quot;value.airSegments.serviceProviderCode&quot; : &quot;AC4&quot;, &quot;value.airSegments.identifier.code&quot; : &quot;123&quot;, &quot;value.airSegments.start.locationCode&quot; : &quot;CDG&quot;, &quot;value.airSegments.end.locationCode&quot; : &quot;YVR&quot;, &quot;value.airSegments.start.date&quot; : &quot;2018-09-25&quot;, &quot;value.airSegments.identifier.suffix&quot; : &quot;A&quot; })&lt;b&gt;.sort({fid:1}).explain(&quot;executionStats&quot;)&lt;/b&gt;&lt;br/&gt;
 {&lt;br/&gt;
 &quot;queryPlanner&quot; : {&lt;br/&gt;
 &quot;plannerVersion&quot; : 1,&lt;br/&gt;
 &quot;namespace&quot; : &quot;sampledb.PassengerNameRecord&quot;,&lt;br/&gt;
 &quot;indexFilterSet&quot; : false,&lt;br/&gt;
 &quot;parsedQuery&quot; : {&lt;br/&gt;
 &quot;$and&quot; : [&lt;br/&gt;
 {&lt;br/&gt;
 &quot;value.airSegments.end.locationCode&quot; : {
 &quot;$eq&quot; : &quot;YVR&quot;
 }&lt;br/&gt;
 },&lt;br/&gt;
 {&lt;br/&gt;
 &quot;value.airSegments.identifier.code&quot; : {
 &quot;$eq&quot; : &quot;123&quot;
 }&lt;br/&gt;
 },&lt;br/&gt;
 {&lt;br/&gt;
 &quot;value.airSegments.identifier.suffix&quot; : {
 &quot;$eq&quot; : &quot;A&quot;
 }&lt;br/&gt;
 },&lt;br/&gt;
 {&lt;br/&gt;
 &quot;value.airSegments.serviceProviderCode&quot; : {
 &quot;$eq&quot; : &quot;AC4&quot;
 }&lt;br/&gt;
 },&lt;br/&gt;
 {&lt;br/&gt;
 &quot;value.airSegments.start.date&quot; : {
 &quot;$eq&quot; : &quot;2018-09-25&quot;
 }&lt;br/&gt;
 },&lt;br/&gt;
 {&lt;br/&gt;
 &quot;value.airSegments.start.locationCode&quot; : {
 &quot;$eq&quot; : &quot;CDG&quot;
 }&lt;br/&gt;
 }&lt;br/&gt;
 ]&lt;br/&gt;
 },&lt;br/&gt;
 &quot;winningPlan&quot; : {&lt;br/&gt;
 &quot;stage&quot; : &quot;SORT&quot;,&lt;br/&gt;
 &quot;sortPattern&quot; : {
 &quot;fid&quot; : 1
 },&lt;br/&gt;
 &quot;inputStage&quot; : {&lt;br/&gt;
 &quot;stage&quot; : &quot;SORT_KEY_GENERATOR&quot;,&lt;br/&gt;
 &quot;inputStage&quot; : {&lt;br/&gt;
 &quot;stage&quot; : &quot;FETCH&quot;,&lt;br/&gt;
 &quot;filter&quot; : {&lt;br/&gt;
 &quot;$and&quot; : [&lt;br/&gt;
 {&lt;br/&gt;
 &quot;value.airSegments.end.locationCode&quot; : {
 &quot;$eq&quot; : &quot;YVR&quot;
 }&lt;br/&gt;
 },&lt;br/&gt;
 {&lt;br/&gt;
 &quot;value.airSegments.identifier.code&quot; : {
 &quot;$eq&quot; : &quot;123&quot;
 }&lt;br/&gt;
 },&lt;br/&gt;
 {&lt;br/&gt;
 &quot;value.airSegments.identifier.suffix&quot; : {
 &quot;$eq&quot; : &quot;A&quot;
 }&lt;br/&gt;
 },&lt;br/&gt;
 {&lt;br/&gt;
 &quot;value.airSegments.start.date&quot; : {
 &quot;$eq&quot; : &quot;2018-09-25&quot;
 }&lt;br/&gt;
 },&lt;br/&gt;
 {&lt;br/&gt;
 &quot;value.airSegments.start.locationCode&quot; : {
 &quot;$eq&quot; : &quot;CDG&quot;
 }&lt;br/&gt;
 }&lt;br/&gt;
 ]&lt;br/&gt;
 },&lt;br/&gt;
 &quot;inputStage&quot; : {&lt;br/&gt;
 &quot;stage&quot; : &quot;IXSCAN&quot;,&lt;br/&gt;
 &quot;keyPattern&quot; : {
 &quot;value.airSegments.serviceProviderCode&quot; : 1,
 &quot;value.airSegments.identifier.code&quot; : 1,
 &quot;value.airSegments.start.locationCode&quot; : 1,
 &quot;value.airSegments.end.locationCode&quot; : 1,
 &quot;value.airSegments.start.date&quot; : -1,
 &quot;value.airSegments.identifier.suffix&quot; : 1
 },&lt;br/&gt;
 &quot;indexName&quot; : &quot;pnrFlightDetailsIdx&quot;,&lt;br/&gt;
 &quot;isMultiKey&quot; : true,&lt;br/&gt;
 &quot;multiKeyPaths&quot; : {
 &quot;value.airSegments.serviceProviderCode&quot; : [
 &quot;value.airSegments&quot;
 ],
 &quot;value.airSegments.identifier.code&quot; : [
 &quot;value.airSegments&quot;
 ],
 &quot;value.airSegments.start.locationCode&quot; : [
 &quot;value.airSegments&quot;
 ],
 &quot;value.airSegments.end.locationCode&quot; : [
 &quot;value.airSegments&quot;
 ],
 &quot;value.airSegments.start.date&quot; : [
 &quot;value.airSegments&quot;
 ],
 &quot;value.airSegments.identifier.suffix&quot; : [
 &quot;value.airSegments&quot;
 ]
 },&lt;br/&gt;
 &quot;isUnique&quot; : false,&lt;br/&gt;
 &quot;isSparse&quot; : false,&lt;br/&gt;
 &quot;isPartial&quot; : false,&lt;br/&gt;
 &quot;indexVersion&quot; : 2,&lt;br/&gt;
 &quot;direction&quot; : &quot;forward&quot;,&lt;br/&gt;
 &quot;indexBounds&quot; : {
 &quot;value.airSegments.serviceProviderCode&quot; : [
 &quot;[\&quot;AC4\&quot;, \&quot;AC4\&quot;]&quot;
 ],
 &quot;value.airSegments.identifier.code&quot; : [
 &quot;[MinKey, MaxKey]&quot;
 ],
 &quot;value.airSegments.start.locationCode&quot; : [
 &quot;[MinKey, MaxKey]&quot;
 ],
 &quot;value.airSegments.end.locationCode&quot; : [
 &quot;[MinKey, MaxKey]&quot;
 ],
 &quot;value.airSegments.start.date&quot; : [
 &quot;[MaxKey, MinKey]&quot;
 ],
 &quot;value.airSegments.identifier.suffix&quot; : [
 &quot;[MinKey, MaxKey]&quot;
 ]
 }&lt;br/&gt;
 }&lt;br/&gt;
 }&lt;br/&gt;
 }&lt;br/&gt;
 },&lt;br/&gt;
 &quot;rejectedPlans&quot; : [&lt;br/&gt;
 {&lt;br/&gt;
 &quot;stage&quot; : &quot;FETCH&quot;,&lt;br/&gt;
 &quot;filter&quot; : {&lt;br/&gt;
 &quot;$and&quot; : [&lt;br/&gt;
 {&lt;br/&gt;
 &quot;value.airSegments.end.locationCode&quot; : {
 &quot;$eq&quot; : &quot;YVR&quot;
 }&lt;br/&gt;
 },&lt;br/&gt;
 {&lt;br/&gt;
 &quot;value.airSegments.identifier.code&quot; : {
 &quot;$eq&quot; : &quot;123&quot;
 }&lt;br/&gt;
 },&lt;br/&gt;
 {&lt;br/&gt;
 &quot;value.airSegments.identifier.suffix&quot; : {
 &quot;$eq&quot; : &quot;A&quot;
 }&lt;br/&gt;
 },&lt;br/&gt;
 {&lt;br/&gt;
 &quot;value.airSegments.serviceProviderCode&quot; : {
 &quot;$eq&quot; : &quot;AC4&quot;
 }&lt;br/&gt;
 },&lt;br/&gt;
 {&lt;br/&gt;
 &quot;value.airSegments.start.date&quot; : {
 &quot;$eq&quot; : &quot;2018-09-25&quot;
 }&lt;br/&gt;
 },&lt;br/&gt;
 {&lt;br/&gt;
 &quot;value.airSegments.start.locationCode&quot; : {
 &quot;$eq&quot; : &quot;CDG&quot;
 }&lt;br/&gt;
 }&lt;br/&gt;
 ]&lt;br/&gt;
 },&lt;br/&gt;
 &quot;inputStage&quot; : {&lt;br/&gt;
 &quot;stage&quot; : &quot;IXSCAN&quot;,&lt;br/&gt;
 &quot;keyPattern&quot; : {
 &quot;fid&quot; : 1
 },&lt;br/&gt;
 &quot;indexName&quot; : &quot;fid_1&quot;,&lt;br/&gt;
 &quot;isMultiKey&quot; : false,&lt;br/&gt;
 &quot;isUnique&quot; : true,&lt;br/&gt;
 &quot;isSparse&quot; : false,&lt;br/&gt;
 &quot;isPartial&quot; : false,&lt;br/&gt;
 &quot;indexVersion&quot; : 1,&lt;br/&gt;
 &quot;direction&quot; : &quot;forward&quot;,&lt;br/&gt;
 &quot;indexBounds&quot; : {
 &quot;fid&quot; : [
 &quot;[MinKey, MaxKey]&quot;
 ]
 }&lt;br/&gt;
 }&lt;br/&gt;
 }&lt;br/&gt;
 ]&lt;br/&gt;
 },&lt;br/&gt;
 &quot;executionStats&quot; : {&lt;br/&gt;
 &quot;executionSuccess&quot; : true,&lt;br/&gt;
 &quot;nReturned&quot; : 0,&lt;br/&gt;
 &quot;executionTimeMillis&quot; : 0,&lt;br/&gt;
 &quot;totalKeysExamined&quot; : 0,&lt;br/&gt;
 &quot;totalDocsExamined&quot; : 0,&lt;br/&gt;
 &quot;executionStages&quot; : {&lt;br/&gt;
 &quot;stage&quot; : &quot;SORT&quot;,&lt;br/&gt;
 &quot;nReturned&quot; : 0,&lt;br/&gt;
 &quot;executionTimeMillisEstimate&quot; : 0,&lt;br/&gt;
 &quot;works&quot; : 4,&lt;br/&gt;
 &quot;advanced&quot; : 0,&lt;br/&gt;
 &quot;needTime&quot; : 2,&lt;br/&gt;
 &quot;needYield&quot; : 0,&lt;br/&gt;
 &quot;saveState&quot; : 0,&lt;br/&gt;
 &quot;restoreState&quot; : 0,&lt;br/&gt;
 &quot;isEOF&quot; : 1,&lt;br/&gt;
 &quot;invalidates&quot; : 0,&lt;br/&gt;
 &quot;sortPattern&quot; : {
 &quot;fid&quot; : 1
 },&lt;br/&gt;
 &quot;memUsage&quot; : 0,&lt;br/&gt;
 &quot;memLimit&quot; : 33554432,&lt;br/&gt;
 &quot;inputStage&quot; : {&lt;br/&gt;
 &quot;stage&quot; : &quot;SORT_KEY_GENERATOR&quot;,&lt;br/&gt;
 &quot;nReturned&quot; : 0,&lt;br/&gt;
 &quot;executionTimeMillisEstimate&quot; : 0,&lt;br/&gt;
 &quot;works&quot; : 2,&lt;br/&gt;
 &quot;advanced&quot; : 0,&lt;br/&gt;
 &quot;needTime&quot; : 1,&lt;br/&gt;
 &quot;needYield&quot; : 0,&lt;br/&gt;
 &quot;saveState&quot; : 0,&lt;br/&gt;
 &quot;restoreState&quot; : 0,&lt;br/&gt;
 &quot;isEOF&quot; : 1,&lt;br/&gt;
 &quot;invalidates&quot; : 0,&lt;br/&gt;
 &quot;inputStage&quot; : {&lt;br/&gt;
 &quot;stage&quot; : &quot;FETCH&quot;,&lt;br/&gt;
 &quot;filter&quot; : {&lt;br/&gt;
 &quot;$and&quot; : [&lt;br/&gt;
 {&lt;br/&gt;
 &quot;value.airSegments.end.locationCode&quot; : {
 &quot;$eq&quot; : &quot;YVR&quot;
 }&lt;br/&gt;
 },&lt;br/&gt;
 {&lt;br/&gt;
 &quot;value.airSegments.identifier.code&quot; : {
 &quot;$eq&quot; : &quot;123&quot;
 }&lt;br/&gt;
 },&lt;br/&gt;
 {&lt;br/&gt;
 &quot;value.airSegments.identifier.suffix&quot; : {
 &quot;$eq&quot; : &quot;A&quot;
 }&lt;br/&gt;
 },&lt;br/&gt;
 {&lt;br/&gt;
 &quot;value.airSegments.start.date&quot; : {
 &quot;$eq&quot; : &quot;2018-09-25&quot;
 }&lt;br/&gt;
 },&lt;br/&gt;
 {&lt;br/&gt;
 &quot;value.airSegments.start.locationCode&quot; : {
 &quot;$eq&quot; : &quot;CDG&quot;
 }&lt;br/&gt;
 }&lt;br/&gt;
 ]&lt;br/&gt;
 },&lt;br/&gt;
 &quot;nReturned&quot; : 0,&lt;br/&gt;
 &quot;executionTimeMillisEstimate&quot; : 0,&lt;br/&gt;
 &quot;works&quot; : 1,&lt;br/&gt;
 &quot;advanced&quot; : 0,&lt;br/&gt;
 &quot;needTime&quot; : 0,&lt;br/&gt;
 &quot;needYield&quot; : 0,&lt;br/&gt;
 &quot;saveState&quot; : 0,&lt;br/&gt;
 &quot;restoreState&quot; : 0,&lt;br/&gt;
 &quot;isEOF&quot; : 1,&lt;br/&gt;
 &quot;invalidates&quot; : 0,&lt;br/&gt;
 &quot;docsExamined&quot; : 0,&lt;br/&gt;
 &quot;alreadyHasObj&quot; : 0,&lt;br/&gt;
 &quot;inputStage&quot; : {&lt;br/&gt;
 &quot;stage&quot; : &quot;IXSCAN&quot;,&lt;br/&gt;
 &quot;nReturned&quot; : 0,&lt;br/&gt;
 &quot;executionTimeMillisEstimate&quot; : 0,&lt;br/&gt;
 &quot;works&quot; : 1,&lt;br/&gt;
 &quot;advanced&quot; : 0,&lt;br/&gt;
 &quot;needTime&quot; : 0,&lt;br/&gt;
 &quot;needYield&quot; : 0,&lt;br/&gt;
 &quot;saveState&quot; : 0,&lt;br/&gt;
 &quot;restoreState&quot; : 0,&lt;br/&gt;
 &quot;isEOF&quot; : 1,&lt;br/&gt;
 &quot;invalidates&quot; : 0,&lt;br/&gt;
 &quot;keyPattern&quot; : {
 &quot;value.airSegments.serviceProviderCode&quot; : 1,
 &quot;value.airSegments.identifier.code&quot; : 1,
 &quot;value.airSegments.start.locationCode&quot; : 1,
 &quot;value.airSegments.end.locationCode&quot; : 1,
 &quot;value.airSegments.start.date&quot; : -1,
 &quot;value.airSegments.identifier.suffix&quot; : 1
 },&lt;br/&gt;
 &quot;indexName&quot; : &quot;pnrFlightDetailsIdx&quot;,&lt;br/&gt;
 &quot;isMultiKey&quot; : true,&lt;br/&gt;
 &quot;multiKeyPaths&quot; : {
 &quot;value.airSegments.serviceProviderCode&quot; : [
 &quot;value.airSegments&quot;
 ],
 &quot;value.airSegments.identifier.code&quot; : [
 &quot;value.airSegments&quot;
 ],
 &quot;value.airSegments.start.locationCode&quot; : [
 &quot;value.airSegments&quot;
 ],
 &quot;value.airSegments.end.locationCode&quot; : [
 &quot;value.airSegments&quot;
 ],
 &quot;value.airSegments.start.date&quot; : [
 &quot;value.airSegments&quot;
 ],
 &quot;value.airSegments.identifier.suffix&quot; : [
 &quot;value.airSegments&quot;
 ]
 },&lt;br/&gt;
 &quot;isUnique&quot; : false,&lt;br/&gt;
 &quot;isSparse&quot; : false,&lt;br/&gt;
 &quot;isPartial&quot; : false,&lt;br/&gt;
 &quot;indexVersion&quot; : 2,&lt;br/&gt;
 &quot;direction&quot; : &quot;forward&quot;,&lt;br/&gt;
 &quot;indexBounds&quot; : {
 &quot;value.airSegments.serviceProviderCode&quot; : [
 &quot;[\&quot;AC4\&quot;, \&quot;AC4\&quot;]&quot;
 ],
 &quot;value.airSegments.identifier.code&quot; : [
 &quot;[MinKey, MaxKey]&quot;
 ],
 &quot;value.airSegments.start.locationCode&quot; : [
 &quot;[MinKey, MaxKey]&quot;
 ],
 &quot;value.airSegments.end.locationCode&quot; : [
 &quot;[MinKey, MaxKey]&quot;
 ],
 &quot;value.airSegments.start.date&quot; : [
 &quot;[MaxKey, MinKey]&quot;
 ],
 &quot;value.airSegments.identifier.suffix&quot; : [
 &quot;[MinKey, MaxKey]&quot;
 ]
 },&lt;br/&gt;
 &quot;keysExamined&quot; : 0,&lt;br/&gt;
 &quot;seeks&quot; : 1,&lt;br/&gt;
 &quot;dupsTested&quot; : 0,&lt;br/&gt;
 &quot;dupsDropped&quot; : 0,&lt;br/&gt;
 &quot;seenInvalidated&quot; : 0&lt;br/&gt;
 }&lt;br/&gt;
 }&lt;br/&gt;
 }&lt;br/&gt;
 }&lt;br/&gt;
 },&lt;br/&gt;
 &quot;serverInfo&quot; : {
 &quot;host&quot; : &quot;mongodb-5-9c8hd&quot;,
 &quot;port&quot; : 27017,
 &quot;version&quot; : &quot;3.6.3&quot;,
 &quot;gitVersion&quot; : &quot;nogitversion&quot;
 },&lt;br/&gt;
 &quot;ok&quot; : 1&lt;br/&gt;
 }&lt;br/&gt;
 &amp;gt;&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;font color=&quot;#212121&quot;&gt;&#160;&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;font color=&quot;#212121&quot;&gt;Mongo version:&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;font color=&quot;#212121&quot;&gt;bash-4.2$ mongod --version&lt;br/&gt;
 db version v3.6.3&lt;br/&gt;
 git version: nogitversion&lt;br/&gt;
 OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 2013&lt;br/&gt;
 allocator: tcmalloc&lt;br/&gt;
 modules: none&lt;br/&gt;
 build environment:&lt;br/&gt;
 distarch: x86_64&lt;br/&gt;
 target_arch: x86_64&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;font color=&quot;#212121&quot;&gt;&#160;&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&lt;font color=&quot;#212121&quot;&gt;After cleaning the plan cache the problem dissappears:&lt;/font&gt;&lt;/b&gt;&lt;br/&gt;
&lt;tt&gt;db.PassengerNameRecord.getPlanCache().clear()&lt;/tt&gt;&lt;br/&gt;
&lt;font color=&quot;#212121&quot;&gt;The collection has 1 index on the filter criteria (&lt;b&gt;that was build on background&lt;/b&gt;), and one index on sort criteria.&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;font color=&quot;#212121&quot;&gt;This record may be related to&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;:&#160;&lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-32943&quot; class=&quot;external-link&quot; rel=&quot;nofollow&quot;&gt;https://jira.mongodb.org/browse/SERVER-32943&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thanks a lot.&lt;/p&gt;

&lt;p&gt;Jose MORALES ARAGON&lt;/p&gt;</description>
                <environment></environment>
        <key id="612632">SERVER-37423</key>
            <summary>query does not use same execution plan w/wo explain(executionStats)</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</type>
                                            <priority id="3" iconUrl="https://jira.mongodb.org/images/icons/priorities/major.svg">Major - P3</priority>
                        <status id="6" iconUrl="https://jira.mongodb.org/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="3">Duplicate</resolution>
                                        <assignee username="backlog-server-triage">Backlog - Triage Team</assignee>
                                    <reporter username="jose.morales">Jose MORALES ARAGON</reporter>
                        <labels>
                    </labels>
                <created>Tue, 2 Oct 2018 12:45:53 +0000</created>
                <updated>Tue, 6 Dec 2022 03:16:49 +0000</updated>
                            <resolved>Thu, 25 Oct 2018 19:46:59 +0000</resolved>
                                                                    <component>Index Maintenance</component>
                                        <votes>0</votes>
                                    <watches>6</watches>
                                                                                                                <comments>
                            <comment id="2021385" author="nick.brewer" created="Tue, 2 Oct 2018 21:55:29 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=jose.morales&quot; class=&quot;user-hover&quot; rel=&quot;jose.morales&quot;&gt;jose.morales&lt;/a&gt; What you&apos;ve described does have the symptoms of a cached plan issue - however &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-32943&quot; title=&quot;Query during background index build can lead to suboptimal cached plan&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-32943&quot;&gt;&lt;del&gt;SERVER-32943&lt;/del&gt;&lt;/a&gt; is specific to queries where the index is being built in the background at the same time that the query is running, and only applies if the index being built in the background would better handle the query. If the index was built before the query was run, you&apos;re most likely not hitting this issue. &lt;/p&gt;

&lt;p&gt;I believe the issue detailed in &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-32452&quot; title=&quot;Replanning may not occur when a plan with an extremely high &amp;#39;works&amp;#39; value is cached&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-32452&quot;&gt;&lt;del&gt;SERVER-32452&lt;/del&gt;&lt;/a&gt; is more likely to cause the behavior you&apos;re seeing. &lt;/p&gt;

&lt;p&gt;-Nick&lt;/p&gt;



</comment>
                            <comment id="2021336" author="jose.morales" created="Tue, 2 Oct 2018 21:16:08 +0000"  >&lt;p&gt;Actually, to help to find the root cause of my issue Ive added all the information I had (comparaison between the query with and without the explain), and this may be a distraction from the source of the problem.&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;If I may reformulate the problem it would be: The query I run (&lt;b&gt;db.myCollection.filter({...}).sort({})&lt;/b&gt; does not use the right execution plan. It takes 5 minutes, when it should take less than 1 second.&lt;/p&gt;

&lt;p&gt;More details:&lt;/p&gt;

&lt;p&gt;1/ It uses an index built in the background (this issue could be related to &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-32943&quot; class=&quot;external-link&quot; rel=&quot;nofollow&quot;&gt;https://jira.mongodb.org/browse/SERVER-32943&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;2/ A clean up of the cache plan solves the issue.&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;This issue is not a duplicate of &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-16895&quot; title=&quot;Users should be able to request that explain not bypass the plan cache&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-16895&quot;&gt;SERVER-16895&lt;/a&gt;, even if the description of the problem is related. Can we reopen it ?&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;Thanks,&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;Jose M Aragon&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;</comment>
                            <comment id="2020656" author="nick.brewer" created="Tue, 2 Oct 2018 15:23:32 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=jose.morales&quot; class=&quot;user-hover&quot; rel=&quot;jose.morales&quot;&gt;jose.morales&lt;/a&gt; This is currently expected - &lt;tt&gt;explain()&lt;/tt&gt; does not use cached plans. There&apos;s an existing ticket open to add functionality that would tell &lt;tt&gt;explain()&lt;/tt&gt; not to bypass the cache: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-16895&quot; title=&quot;Users should be able to request that explain not bypass the plan cache&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-16895&quot;&gt;SERVER-16895&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can vote for that ticket, and follow along with it for updates. &lt;/p&gt;

&lt;p&gt;-Nick&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10010">
                    <name>Duplicate</name>
                                            <outwardlinks description="duplicates">
                                        <issuelink>
            <issuekey id="179106">SERVER-16895</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>3.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                <customfield id="customfield_12751" key="com.atlassian.jira.plugin.system.customfieldtypes:multiselect">
                        <customfieldname>Assigned Teams</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="25137"><![CDATA[Server Triage]]></customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Tue, 2 Oct 2018 15:23:32 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        5 years, 19 weeks, 1 day ago
    
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_18254" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Dependencies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue><![CDATA[]]></customfieldvalue>


                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_10057" key="com.atlassian.jira.toolkit:lastusercommented">
                        <customfieldname>Last comment by Customer</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>true</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_10056" key="com.atlassian.jira.toolkit:lastupdaterorcommenter">
                        <customfieldname>Last commenter</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>alexander.golin@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            5 years, 19 weeks, 1 day ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                    <customfield id="customfield_10032" key="com.atlassian.jira.plugin.system.customfieldtypes:select">
                        <customfieldname>Operating System</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10026"><![CDATA[ALL]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>backlog-server-triage</customfieldvalue>
            <customfieldvalue>jose.morales</customfieldvalue>
            <customfieldvalue>nick.brewer</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hu9blj:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|htzp93:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>9223372036854775807</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_23361" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Requested By</customfieldname>
                        <customfieldvalues>
                                

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <customfield id="customfield_10053" key="com.atlassian.jira.ext.charting:timeinstatus">
                        <customfieldname>Time In Status</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_22870" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Triagers</customfieldname>
                        <customfieldvalues>
                                

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_14350" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>serverRank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hu8xuv:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                    </customfields>
    </item>
</channel>
</rss>