Skip to content
This repository has been archived by the owner on Aug 10, 2024. It is now read-only.

dbContext.DBSet.FirstOrDefault(e => e.FirstName == "xx") missing filter in MongoQueryable #32

Open
IvanZheng opened this issue Dec 11, 2018 · 5 comments

Comments

@IvanZheng
Copy link

IvanZheng commented Dec 11, 2018

zooDbContext.Employees .FirstOrDefault(e => e.FirstName == "xx") will retrieve all records from employees collection in mongodb.

Reproduce step:

  1. Open mongo shell and use the command "db.setProfilingLevel(2)" to open the query profiler.
  2. Execute zooDbContext.Employees .FirstOrDefault(e => e.FirstName == "xx") in test case.
  3. Use db.system.profile.find().sort({$natural:-1}) to view the profiler data.
    From the profiler data, we can see there is no filter or pipeline in the command.

`

{
"op" : "command",
"ns" : "zooDb.employees",
"command" : {
    "aggregate" : "employees",
    "pipeline" : [],
    "cursor" : {},
    "$db" : "zooDb",
    "lsid" : {
        "id" : UUID("5854cdca-ee1e-44d2-8098-5d1ae3ed06a3")
    }
},
"keysExamined" : 0,
"docsExamined" : 2,
"cursorExhausted" : true,
"numYield" : 0,
"locks" : {
    "Global" : {
        "acquireCount" : {
            "r" : NumberLong(4)
        }
    },
    "Database" : {
        "acquireCount" : {
            "r" : NumberLong(2)
        }
    },
    "Collection" : {
        "acquireCount" : {
            "r" : NumberLong(2)
        }
    }
},
"nreturned" : 2,
"responseLength" : 422,
"protocol" : "op_msg",
"millis" : 0,
"planSummary" : "COLLSCAN",
"ts" : ISODate("2018-12-11T09:05:25.129Z"),
"client" : "127.0.0.1",
"allUsers" : [],
"user" : ""

}

`

@IvanZheng
Copy link
Author

@crhairr, Can you reproduce this issue?

@crhairr
Copy link
Member

crhairr commented Dec 20, 2018

I'm still working on the sub-document update issue. I did some preliminary tests and my local logs show queries going through.

@IvanZheng
Copy link
Author

If your tests are OK, please provide the code or commit to the repo so that I can verify it on my computer. Thanks!

@crhairr
Copy link
Member

crhairr commented Feb 6, 2019

I've been working on a substantial re-write of the metadata tracking system. In the process, I think I may have found part of the issue which is that certain layers of the EF Core query system result in overriding the underlying query provider a basic enumerating provider. I've seen where in some cases, the entire query can be detached from the underlying provider, resulting in enumerating the entire collection from the DB and filtering in-memory on the client.

I've started some changes to address this. I need to finish the current set of changes, and then I can work on things like being able to log the effective query and testing that the correct query goes to the server.

@crhairr
Copy link
Member

crhairr commented Mar 2, 2019

After I finally dealt with the issues that were wrong with the owned/complex EntityType models, I got started on this and found that I have to rewrite a substantial amount of the query processing code in order to get Includes to work correctly and to work around navigation injections for owned documents. I have a branch where everything but the includes are working, but I'm still working on getting the Include compiler finalized.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants