summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2010-02-12 06:58:43 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2010-02-12 06:58:43 +0000
commit9ce1c6339f7f303e533b0728452cac79367efc38 (patch)
tree3e1c5466ff1d125a29b2d311c2bf7129b7b8c185 /includes
parent8bd39cd9813ac4c1253867191e132d903e7f158b (diff)
downloadbrdo-9ce1c6339f7f303e533b0728452cac79367efc38.tar.gz
brdo-9ce1c6339f7f303e533b0728452cac79367efc38.tar.bz2
#550124 by c960657, catch, and Crell: Remove prepared statement caching, which was a nice idea, but uses up tons of memory without any tangible performance benefits.
Diffstat (limited to 'includes')
-rw-r--r--includes/database/database.inc34
-rw-r--r--includes/database/pgsql/database.inc4
-rw-r--r--includes/database/sqlite/database.inc5
3 files changed, 9 insertions, 34 deletions
diff --git a/includes/database/database.inc b/includes/database/database.inc
index d30fab1bc..016b90ba4 100644
--- a/includes/database/database.inc
+++ b/includes/database/database.inc
@@ -202,16 +202,6 @@ abstract class DatabaseConnection extends PDO {
protected $logger = NULL;
/**
- * Cache of prepared statements.
- *
- * This cache only lasts as long as the current page request, so it's not
- * as useful as it could be, but every little bit helps.
- *
- * @var Array
- */
- protected $preparedStatements = array();
-
- /**
* Track the number of "layers" of transactions currently active.
*
* On many databases transactions cannot nest. Instead, we track
@@ -446,26 +436,14 @@ abstract class DatabaseConnection extends PDO {
* @param $query
* The query string as SQL, with curly-braces surrounding the
* table names.
- * @param $cache
- * Whether or not to cache the prepared statement for later reuse in this
- * same request. Usually we want to, but queries that require preprocessing
- * cannot be safely cached.
* @return DatabaseStatementInterface
* A PDO prepared statement ready for its execute() method.
*/
- public function prepareQuery($query, $cache = TRUE) {
+ public function prepareQuery($query) {
$query = $this->prefixTables($query);
- if (isset($this->preparedStatements[$query])) {
- $stmt = $this->preparedStatements[$query];
- }
- else {
- // Call PDO::prepare.
- $stmt = parent::prepare($query);
- if ($cache) {
- $this->preparedStatements[$query] = $stmt;
- }
- }
- return $stmt;
+
+ // Call PDO::prepare.
+ return parent::prepare($query);
}
/**
@@ -581,8 +559,8 @@ abstract class DatabaseConnection extends PDO {
$stmt->execute(NULL, $options);
}
else {
- $modified = $this->expandArguments($query, $args);
- $stmt = $this->prepareQuery($query, !$modified);
+ $this->expandArguments($query, $args);
+ $stmt = $this->prepareQuery($query);
$stmt->execute($args, $options);
}
diff --git a/includes/database/pgsql/database.inc b/includes/database/pgsql/database.inc
index a42e377cb..841be2296 100644
--- a/includes/database/pgsql/database.inc
+++ b/includes/database/pgsql/database.inc
@@ -69,8 +69,8 @@ class DatabaseConnection_pgsql extends DatabaseConnection {
$stmt->execute(NULL, $options);
}
else {
- $modified = $this->expandArguments($query, $args);
- $stmt = $this->prepareQuery($query, !$modified);
+ $this->expandArguments($query, $args);
+ $stmt = $this->prepareQuery($query);
$stmt->execute($args, $options);
}
diff --git a/includes/database/sqlite/database.inc b/includes/database/sqlite/database.inc
index f175732f7..17d9034a9 100644
--- a/includes/database/sqlite/database.inc
+++ b/includes/database/sqlite/database.inc
@@ -161,10 +161,7 @@ class DatabaseConnection_sqlite extends DatabaseConnection {
return isset($specials[$operator]) ? $specials[$operator] : NULL;
}
- public function prepareQuery($query, $cache = TRUE) {
- // It makes no sense to use the static prepared statement cache here,
- // because all the work in our implementation is done in
- // DatabaseStatement_sqlite::execute() and cannot be cached.
+ public function prepareQuery($query) {
return $this->prepare($this->prefixTables($query));
}