[DEVPLAT-6367] Add performance related configuration settings #155
+126
−64
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
In this PR we are extending the Database configuration settings. Those configuration settings may help improving performance of the SQL operations in certain cases.
DisableDefaultGormTransactionGORM performs write (create/update/delete) operations inside a transaction to ensure data consistency, which is bad for performance. It can be disabled with this setting to
trueCachePreparedStatementsIf set to
true, creates a prepared statement when executing any SQL and caches them to speed up future calls.MysqlInterpolateParamsIf set to
true, placeholders (?) in calls to db.Query() and db.Exec() are interpolated into a single query string with given parameters. This reduces the number of roundtrips, since the driver has to prepare a statement, execute it with given parameters and close the statement again with interpolateParams=false.Checklist
Thoroughly tested the changes indevelopmentand/orstagingUpdated theREADME.mdas necessaryRelated links
Note
Adds new DB performance settings and applies them to GORM (transactions/prepared statements) and MySQL DSN (interpolateParams), with tests and docs updated.
pkg/database/config.go): Adddisable_default_gorm_transaction,cache_prepared_statements,mysql_interpolate_params.pkg/database/connection_details.go): Passmysql_interpolate_params; includeinterpolateParams=truein DSN opts when enabled.pkg/database/gorm.go): RespectDisableDefaultGormTransaction(SkipDefaultTransaction) andCachePreparedStatements(PrepareStmt).config_test.goandconnection_details_test.goto assert new config fields and DSN option.Written by Cursor Bugbot for commit 9dc579b. This will update automatically on new commits. Configure here.