|
|
|
|
|
by 10000truths
1130 days ago
|
|
> Using SQL comments for tracing served as a “cache buster” — apparently the generic plan cache is keyed on the raw text of the query! Keying user-provided data without canonicalizing it first, a classic oopsie that's bitten plenty in the arse. |
|
Furthermore in many databases, comments aren't always "just comments." For instance MySQL can specify nonstandard or version-specific syntax inside of comments and it will be executed. The 'STRAIGHT JOIN' below is an example from their docs and here is not a comment, but a mysql-specific part of the statement:
SELECT /*! STRAIGHT_JOIN */ col1 FROM table1,table2 WHERE ...
I dare say the worst offense here is enabling SQLAlchemy's Instrumentation in production without understanding how it might impact database performance. Even though some of these behaviors ended up causing unexpected problems, overall the instrumentation was clearly preventing some common queries from being potentially optimized by the query planner, and it may have been interfering with the buffer cache, query statistics, or other optimization mechanics as well.