| 159 | } |
| 160 | |
| 161 | Reference<Plan> planQuery(Reference<UnboundCollectionContext> cx, bson::BSONObj const& query) { |
| 162 | auto predicate = queryToPredicate(query, true); |
| 163 | auto simplifiedPredicate = predicate->simplify(); |
| 164 | |
| 165 | Reference<Plan> plan = Reference<Plan>( |
| 166 | FilterPlan::construct_filter_plan(cx, Reference<Plan>(new TableScanPlan(cx)), simplifiedPredicate)); |
| 167 | if (verboseConsoleOutput) { |
| 168 | fprintf(stderr, "parsed predicate: %s\n", predicate->toString().c_str()); |
| 169 | fprintf(stderr, " simplified to: %s\n\n", simplifiedPredicate->toString().c_str()); |
| 170 | } |
| 171 | if (verboseLogging) { |
| 172 | TraceEvent("BD_GetMatchingDocs") |
| 173 | .detail("QueryPredicate", predicate->toString()) |
| 174 | .detail("SimplifiedPredicate", predicate->toString()) |
| 175 | .detail("Plan", plan->describe().toString()); |
| 176 | } |
| 177 | |
| 178 | if (slowQueryLogging && plan->hasScanOfType(PlanType::TableScan)) { |
| 179 | std::string collectionName = cx->collectionName(); |
| 180 | if (!startsWith(collectionName.c_str(), "system.")) |
| 181 | TraceEvent("SlowQuery") |
| 182 | .detail("Database", cx->databaseName()) |
| 183 | .detail("Collection", collectionName) |
| 184 | .detail("Query", query.toString()) |
| 185 | .detail("Plan", plan->describe().toString()); |
| 186 | } |
| 187 | |
| 188 | return plan; |
| 189 | } |
| 190 | |
| 191 | Reference<Plan> planProjection(Reference<Plan> plan, |
| 192 | bson::BSONObj const& selector, |
no test coverage detected