Skip to content

[RFC]: Sql Statement Query Caching #112

@simon-mundy

Description

@simon-mundy

Proposed Version

0.6.0

Basic Information

PhpDb manually compiles each Select query for every single query, creating unnecessary overhead when a query itself will not change based on adapter/platform.

The intention of this proposal is to allow a caching mechanism which would determine if a Statement uses a Parameter Container and if so, store the compiled query in a cache that is user-determined. This still allows the database driver to correctly quote/execute data without needing to cache-bust regularly.

Background

No response

Considerations

No response

Proposal(s)

Sample pseudo code:-

$select->from('foo')->where([
    'c1' => null,
    'c2' => [1, 2, 3],
    new \Laminas\Db\Sql\Predicate\IsNotNull('c3'),
]);
// Cached string is 'SELECT "foo".* FROM "foo" WHERE "c1" IS NULL AND "c2" IN (?, ?, ?) AND "c3" IS NOT NULL'

$statement = $sql->prepareStatementForSqlObject($select, $storage); // where $storage is a PSR-6 compliant storage wrapper
$results = $statement->execute(); // Statement will use pre-prepared SQL string based on driver/adapter/platform

Appendix/Additional Info

No response

Metadata

Metadata

Assignees

Labels

Lang Feature RefactorRefactoring to new language featuresenhancementNew feature or requestqaImprovements in quality assurance of the project

Projects

Status

Todo

Relationships

None yet

Development

No branches or pull requests

Issue actions