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

Method findJoinOrder

src/jrd/optimizer/InnerJoin.cpp:285–345  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

283//
284
285bool InnerJoin::findJoinOrder()
286{
287 bestStreams.clear();
288 bestCount = 0;
289 remainingStreams = 0;
290
291#ifdef OPT_DEBUG
292 // Debug
293 printStartOrder();
294#endif
295
296 for (const auto innerStream : innerStreams)
297 {
298 if (!innerStream->used)
299 {
300 remainingStreams++;
301
302 if (innerStream->isIndependent())
303 {
304 if (!bestCount || innerStream->baseCost < bestCost)
305 {
306 bestStreams.resize(1);
307 bestStreams.front().number = innerStream->number;
308 bestCount = 1;
309 bestCost = innerStream->baseCost;
310 }
311 }
312 }
313 }
314
315 if (bestCount == 0)
316 {
317 IndexedRelationships indexedRelationships;
318
319 for (const auto innerStream : innerStreams)
320 {
321 if (!innerStream->used)
322 {
323 indexedRelationships.clear();
324 findBestOrder(0, innerStream, indexedRelationships, 0.0, 1.0);
325
326 if (plan) // if an explicit PLAN was specified we should be ready
327 break;
328 }
329 }
330 }
331
332 // Mark streams as used
333 for (const auto& stream : bestStreams)
334 {
335 auto streamInfo = getStreamInfo(stream.number);
336 streamInfo->used = true;
337 }
338
339#ifdef OPT_DEBUG
340 // Debug
341 printBestOrder();
342#endif

Callers 2

formRiversMethod · 0.80
generateInnerJoinMethod · 0.80

Calls 5

isIndependentMethod · 0.80
clearMethod · 0.45
resizeMethod · 0.45
frontMethod · 0.45
hasDataMethod · 0.45

Tested by

no test coverage detected