mongodb-d4
mongodb-d4 copied to clipboard
Prune Empty Sessions + Operations
trafficstars
The SQL->Mongo workload traces sometimes contain sessions without any operations. We should just check when we're creating a session whether it actually has any operations and prune them if they don't.
From the epinions workload:
> db.sessions.findOne({'operations': {$size: 0}})
{ "_id" : ObjectId("4f9be5207ea57382dd0235ae"),
"ip2" : "10.0.1.2",
"operations" : [ ],
"ip1" : "127.0.0.1",
"uid" : 6018 }
There are also queries that don't have any content at all. I'm not sure whether this should be a full scan of the collection or whether it's just junk data:
> db.sessions.find({'operations.content.query': null}, {}).count()
2970
There is a operation in the epinions workload that has a null WHERE clause for an update:
> db.sessions.findOne({"_id": ObjectId("4f9c68f67ea5738a7f022eed")})
{
"_id" : ObjectId("4f9c68f67ea5738a7f022eed"),
"ip2" : "192.168.63.1",
"operations" : [
{
"timestamp" : 1335551334,
"collection" : "item",
"content" : [
null,
{
"jBbkw" : "j",
"title" : ""
}
],
"output" : [ ],
"type" : "$update",
"size" : 0
}
],
"ip1" : "127.0.0.1",
"uid" : 4289
}
The first issue of empty sessions has been resovled.