Skip to content

Commit

Permalink
Fixes #7049: Performance issue with table existence query (#7050)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeawhanlee authored Oct 29, 2024
1 parent fa4a2da commit 9f3b827
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions inc/Engine/Common/Database/Queries/AbstractQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -520,8 +520,8 @@ protected function table_exists(): bool {
}

// Query statement.
$query = 'SELECT table_name FROM information_schema.tables WHERE table_name = %s LIMIT 1';
$prepared = $db->prepare( $query, $db->{$this->table_name} );
$query = 'SELECT table_name FROM information_schema.tables WHERE table_schema = %s AND table_name = %s LIMIT 1';
$prepared = $db->prepare( $query, $db->__get( 'dbname' ), $db->{$this->table_name} );
$result = $db->get_var( $prepared );

// Does the table exist?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ protected function table_exists(): bool {
}

// Query statement.
$query = 'SELECT table_name FROM information_schema.tables WHERE table_name = %s LIMIT 1';
$prepared = $db->prepare( $query, $db->{$this->table_name} );
$query = 'SELECT table_name FROM information_schema.tables WHERE table_schema = %s AND table_name = %s LIMIT 1';
$prepared = $db->prepare( $query, $db->__get( 'dbname' ), $db->{$this->table_name} );
$result = $db->get_var( $prepared );

// Does the table exist?
Expand Down

0 comments on commit 9f3b827

Please sign in to comment.