Skip to content

Commit

Permalink
don't analyse maybe existing data when QueryPlanAnalyzer::TABLES_WITH…
Browse files Browse the repository at this point in the history
…OUT_DATA (#402)

Co-authored-by: Markus Staab <m.staab@complex-it.de>
  • Loading branch information
staabm and clxmstaab authored Jun 8, 2022
1 parent daca8a0 commit a620e0e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Analyzer/QueryPlanAnalyzerMysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ private function buildResult(string $simulatedQuery, $it): QueryPlanResult
}

foreach ($it as $row) {
// we cannot analyse tables without rows -> mysql will just return 'no matching row in const table'
// mysql might return 'no matching row in const table'
if (null === $row['table']) {
continue;
}
Expand All @@ -91,6 +91,11 @@ private function buildResult(string $simulatedQuery, $it): QueryPlanResult

$result->addRow($row['table'], QueryPlanResult::NO_INDEX);
} else {
// don't analyse maybe existing data, to make the result consistent with empty db schemas
if (QueryPlanAnalyzer::TABLES_WITHOUT_DATA === $allowedRowsNotRequiringIndex) {
continue;
}

if (null !== $row['type'] && 'all' === strtolower($row['type']) && $row['rows'] >= $allowedRowsNotRequiringIndex) {
$result->addRow($row['table'], QueryPlanResult::TABLE_SCAN);
} elseif (true === $allowedUnindexedReads && $row['rows'] >= QueryPlanAnalyzer::DEFAULT_UNINDEXED_READS_THRESHOLD) {
Expand Down

0 comments on commit a620e0e

Please sign in to comment.