Skip to content

Commit a620e0e

Browse files
staabmclxmstaab
andauthored
don't analyse maybe existing data when QueryPlanAnalyzer::TABLES_WITHOUT_DATA (#402)
Co-authored-by: Markus Staab <[email protected]>
1 parent daca8a0 commit a620e0e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Analyzer/QueryPlanAnalyzerMysql.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ private function buildResult(string $simulatedQuery, $it): QueryPlanResult
7777
}
7878

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

9292
$result->addRow($row['table'], QueryPlanResult::NO_INDEX);
9393
} else {
94+
// don't analyse maybe existing data, to make the result consistent with empty db schemas
95+
if (QueryPlanAnalyzer::TABLES_WITHOUT_DATA === $allowedRowsNotRequiringIndex) {
96+
continue;
97+
}
98+
9499
if (null !== $row['type'] && 'all' === strtolower($row['type']) && $row['rows'] >= $allowedRowsNotRequiringIndex) {
95100
$result->addRow($row['table'], QueryPlanResult::TABLE_SCAN);
96101
} elseif (true === $allowedUnindexedReads && $row['rows'] >= QueryPlanAnalyzer::DEFAULT_UNINDEXED_READS_THRESHOLD) {

0 commit comments

Comments
 (0)