MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / compileRelation

Method compileRelation

src/jrd/optimizer/Optimizer.cpp:1222–1257  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1220//
1221
1222void Optimizer::compileRelation(StreamType stream)
1223{
1224 // We have found a base relation; record its stream number in the streams array
1225 // as a candidate for merging into a river
1226
1227 compileStreams.add(stream);
1228
1229 // If we have any booleans or sort fields, we may be able to
1230 // use an index to optimize them; retrieve the current format of
1231 // all indices at this time so we can determine if it's possible
1232
1233 const bool needIndices = conjuncts.hasData() || (rse->rse_sorted || rse->rse_aggregate);
1234
1235 const auto tail = &csb->csb_rpt[stream];
1236
1237 const auto relation = tail->csb_relation;
1238 fb_assert(relation);
1239
1240 tail->csb_idx = nullptr;
1241
1242 if (needIndices && !relation->rel_file && !relation->isVirtual())
1243 {
1244 const auto relPages = relation->getPages(tdbb);
1245 IndexDescList idxList;
1246 BTR_all(tdbb, relation, idxList, relPages);
1247
1248 if (idxList.hasData())
1249 tail->csb_idx = FB_NEW_POOL(getPool()) IndexDescList(getPool(), idxList);
1250
1251 if (tail->csb_plan)
1252 markIndices(tail, relation->rel_id);
1253 }
1254
1255 const auto format = CMP_format(tdbb, csb, stream);
1256 tail->csb_cardinality = getCardinality(tdbb, relation, format);
1257}
1258
1259
1260//

Callers 1

compileMethod · 0.80

Calls 8

BTR_allFunction · 0.85
markIndicesFunction · 0.85
CMP_formatFunction · 0.85
getCardinalityFunction · 0.85
isVirtualMethod · 0.80
addMethod · 0.45
hasDataMethod · 0.45
getPagesMethod · 0.45

Tested by

no test coverage detected