-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prepared statements #39
Comments
I'm working on adding sql commenter to elixir ecto. We often have problems to find where a query originates from. select id from users /*app='myapp',caller='UserController.get_id',team=`team_users`*/
select id from users /*app='myapp',caller='SessionController.get_id',team=`team_login`*/
select id from users /*app='myapp',caller='JobRunner.send_email',team=`team_emails`*/ The problems start to arise when you start adding more dynamic data like session_id or traces. I plan to allow this with some kind of switch, when I need traces I could add a feature flag and disable prepared statements for these queries. |
Maybe DB drivers should track query execution time and if a prepared query takes more than X ms do a run where it injects the tracing info and then go back to using the prepared query? So something akin to sampling. |
I think it should be something that runs along the query and stores execution times somewhere? but you know the execution time after the query is run - its too late to inject the data. At this point you can only log it. Also when you add the comment metadata then the execution play may be completly different than it was on a slow prepared statement. |
I’m curious what the sqlcommenter story is with prepared statements. At least in Postgres there is, for obvious reasons, no way to inject data into prepared statements without re-preparing it every time (various things in the pipeline, client libraries, poolers and Postgres itself hash query text).
Is there any work in progress to discuss with the databases themselves a solution to inject metadata into queries without hacking through comments?
The text was updated successfully, but these errors were encountered: