From 7c0113d4ee5da58337ff0f794241d1e11f783c3b Mon Sep 17 00:00:00 2001 From: David Grudl Date: Tue, 20 Nov 2018 15:44:17 +0100 Subject: [PATCH] PgSqlDriver: uses cache for getColumnTypes() to avoid excessive number of queries [Closes #212] --- src/Database/Drivers/PgSqlDriver.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Database/Drivers/PgSqlDriver.php b/src/Database/Drivers/PgSqlDriver.php index c943bb8ca..0b3217e2e 100644 --- a/src/Database/Drivers/PgSqlDriver.php +++ b/src/Database/Drivers/PgSqlDriver.php @@ -218,7 +218,12 @@ public function getForeignKeys(string $table): array public function getColumnTypes(\PDOStatement $statement): array { - return Nette\Database\Helpers::detectTypes($statement); + static $cache; + $item = &$cache[$statement->queryString]; + if ($item === null) { + $item = Nette\Database\Helpers::detectTypes($statement); + } + return $item; }