-
-
Notifications
You must be signed in to change notification settings - Fork 142
Description
- Is your feature request related to a problem?
Our SQL Server DBAs have alerted us to the fact that the parameterized queries passed through Dibi are replaced with hardcoded values sent in the SQL request to the Database.
I.e.DECLARE @userID INT = %i;is replaced withDECLARE @userID INT = 123;
This causes the DB query plan to be constantly discarded and regenerated whereas if the SQL query sent to the DB server still contains the query markers ('?') the generated SQL query plan could be reused with different query parameter values that are passed in as well. This allows SQL Server (in our case but assuming this applies to other DBs as well) to generate a reusable query plan. I.e. DECLARE @userID INT = %i; is replaced with DECLARE @userID INT = ? and the query parameter is passed through to the DB server to apply the parameter value to the query plan.
-
Explain your intentions.
It would be nice to have a configuration option per Dibi\Connection or better yet per query function call that would allow the generated SQL string to perform the parameter substitution on either the PHP Web Server side or pass through the parameterized queries to the DB server side. Reqardless of when the parameterization resolution occurs in all cases Dibi should still perform type checking on query parameters and fail fast (pre DB call) if parameter input does not match expectations. -
It's up to you to make a strong case to convince the project's developers of the merits of this feature.
This functionality is absolutely necessary for large scale solutions. If Dibi forces the underlying DB server to constantly re-evaluate query plans for every Adhoc sql query this will not handle significant DB load nor is it performant or efficient on the DB server.