[SERVER-56297] error explain for one secondary Created: 23/Apr/21  Updated: 27/Oct/23  Resolved: 04/May/21

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: h jy Assignee: Edwin Zhou
Resolution: Works as Designed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-56298 error explain for one secondary Closed
Operating System: ALL
Participants:

 Description   

Hi  support, 

     we find  our queris use the error index  by slow logs  :

//2021-04-23T00:34:31.408+0800 I COMMAND  [conn1525857] command region_governance.area_info command: count { count: "area_info", query: { cityCode: { $in: [ "021" ] }, templateGuid: { $in: [ "T_536751178985275392" ] }, businessType: { $in: [ 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31 ] }, areaStatus: { $in: [ 5 ] }, isDelete: 0 }, $db: "region_governance", $clusterTime: { clusterTime: Timestamp(1619109260, 35), signature: { hash: BinData(0, 89550148FC85585EE9B2ACA9D09E724805A8AEE0), keyId: 6918301327185412097 } }, lsid: { id: UUID("eb4fc071-0048-4cd7-8064-6cb49f5a5fa8") }, $readPreference: { mode: "secondary" } } planSummary: IXSCAN { cityCode: 1, templateType: 1, businessType: 1, operateType: 1, operateUnit: 1, 1000000002: 1 } keysExamined:55686 docsExamined:55670 numYields:438 reslen:170 locks:{ Global: { acquireCount: { r: 439 } }, Database: { acquireCount: { r: 439 } }, Collection: { acquireCount: { r: 439 } } } storage:{} protocol:op_msg 9648ms

    1.we execute  the query on mono shell and get the correct explain which on 'index' file,

    2.we hint the error index and get the slow log's explain which on 'index1' file,

    3. this is a replset , other secondary don't have the issue.    



 Comments   
Comment by Edwin Zhou [ 04/May/21 ]

Hi 18621325186@163.com,

I'm not quite sure what is the issue you're seeing; slow logs are expected when a query takes longer than 100ms. It sounds like you're forcing an index to be used with performing a query using $hint. Looking at the slow log, the index you've chosen does not appear to be optimal. The query examines 55k keys and 55k documents, which would explain why the query is slower. I recommend taking a look at Indexing Strategies to get a better sense of how to optimize your indexes for your use cases.

As a reminder, please note that the SERVER project is for bugs and feature suggestions for the MongoDB server. As this ticket does not appear to be a bug, I will now close it. If you need further assistance troubleshooting, I encourage you to ask our community by posting on the MongoDB Developer Community Forums. If your discussion there leads you to believe that you've reached a bug, please follow up here and we will be happy to reopen this ticket!

Best,
Edwin

Generated at Thu Feb 08 05:38:54 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.