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

Method getIndexedRelationships

src/jrd/optimizer/InnerJoin.cpp:633–686  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

631//
632
633void InnerJoin::getIndexedRelationships(StreamInfo* testStream)
634{
635#ifdef OPT_DEBUG_RETRIEVAL
636 const auto name = optimizer->getStreamName(testStream->number);
637 optimizer->printf("Dependencies for stream %u (%s):\n",
638 testStream->number, name.c_str());
639#endif
640
641 const auto tail = &csb->csb_rpt[testStream->number];
642
643 Retrieval retrieval(tdbb, optimizer, testStream->number, false, false, nullptr, true);
644 const auto candidate = retrieval.getInversion();
645
646 for (const auto baseStream : innerStreams)
647 {
648 if (baseStream->number != testStream->number &&
649 candidate->dependentFromStreams.exist(baseStream->number))
650 {
651 // If the base stream already depends on the testing stream, don't store it again
652 bool found = false;
653 for (const auto& relationship : baseStream->indexedRelationships)
654 {
655 if (relationship.stream == testStream->number)
656 {
657 found = true;
658 break;
659 }
660 }
661
662 if (found)
663 continue;
664
665 if (candidate->dependentFromStreams.getCount() > IndexRelationship::MAX_DEP_STREAMS)
666 continue;
667
668 // If we could use more conjunctions on the testing stream
669 // with the base stream active as without the base stream
670 // then the test stream has a indexed relationship with the base stream.
671 IndexRelationship indexRelationship;
672 indexRelationship.stream = testStream->number;
673 indexRelationship.unique = candidate->unique;
674 indexRelationship.cost = candidate->cost;
675 indexRelationship.cardinality = candidate->unique ?
676 tail->csb_cardinality : tail->csb_cardinality * candidate->selectivity;
677
678 for (const auto depStream : candidate->dependentFromStreams)
679 indexRelationship.depStreams.add(depStream);
680
681 // Relationships are kept sorted by cost and uniqueness in the array
682 baseStream->indexedRelationships.add(indexRelationship);
683 testStream->previousExpectedStreams++;
684 }
685 }
686}
687
688
689//

Callers

nothing calls this directly

Calls 7

getStreamNameMethod · 0.80
getInversionMethod · 0.80
printfMethod · 0.45
c_strMethod · 0.45
existMethod · 0.45
getCountMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected