From b638cc4a4e241146e151be4afaeb1ad2eb6766ef Mon Sep 17 00:00:00 2001 From: Brandon Kelly Date: Sat, 8 Jun 2019 12:48:35 -0700 Subject: [PATCH] Fixes #17348: Improved performance of `yii\db\Connection::quoteTableName()` --- framework/CHANGELOG.md | 1 + framework/db/Connection.php | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index bcdffbc..99cdb9c 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -6,6 +6,7 @@ Yii Framework 2 Change Log - Bug #17341: Fixed error from yii.activeForm.js in strict mode (mikehaertl) - Enh #17345: Improved performance of `yii\db\Connection::quoteColumnName()` (brandonkelly) +- Enh #17348: Improved performance of `yii\db\Connection::quoteTableName()` (brandonkelly) 2.0.20 June 04, 2019 diff --git a/framework/db/Connection.php b/framework/db/Connection.php index 1d50104..3feb085 100644 --- a/framework/db/Connection.php +++ b/framework/db/Connection.php @@ -442,6 +442,10 @@ class Connection extends Component */ private $_queryCacheInfo = []; /** + * @var string[] quoted table name cache for [[quoteTableName()]] calls + */ + private $_quotedTableNames; + /** * @var string[] quoted column name cache for [[quoteColumnName()]] calls */ private $_quotedColumnNames; @@ -895,7 +899,10 @@ class Connection extends Component */ public function quoteTableName($name) { - return $this->getSchema()->quoteTableName($name); + if (isset($this->_quotedTableNames[$name])) { + return $this->_quotedTableNames[$name]; + } + return $this->_quotedTableNames[$name] = $this->getSchema()->quoteTableName($name); } /**