You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Many SQL libraries use named parameters when building queries. This results in queries that look like this when they are pulled from the library and sent in the trace:
SELECT*FROM sale_fee LEFT JOIN fee_type ON ( sale_fee.fee_type_id=fee_type.id )
WHEREsale_fee.sale_code= :p1 ANDfee_type.fee_calculation_typeIN ( :p2, :p3, :p4, :p5 )
It seems like it would be possible to translate these named parameters to regular ? placeholders, and then apply the normal filtering/grouping rules to them in order to reduce cardinality. Named params can be identified by the colon prefix.
SELECT*FROM sale_fee LEFT JOIN fee_type ON ( sale_fee.fee_type_id=fee_type.id )
WHEREsale_fee.sale_code= ? ANDfee_type.fee_calculation_typeIN ( ? )
The text was updated successfully, but these errors were encountered:
gbbr
changed the title
Group named parameters in SQL query
quantizer: group named parameters in SQL query
May 28, 2018
A similar problem we are seeing right now in Mercari, that seems to be partially implied by the description above, is that even multiple unnamed placeholders in IN() are not merged. E.g. optionally I would something like the following (that is common when you have endpoints that accept a variable number of objects):
SELECT * FROM table WHERE id IN (?, ?, ?, ?)
SELECT * FROM table WHERE id IN (?, ?, ?, ?, ?)
SELECT * FROM table WHERE id IN (?, ?, ?, ?, ?, ?)
to be presented as:
SELECT * FROM table WHERE id IN (?)
(or maybe IN (??), to signify that multiple placeholders have been merged?)
This would help to avoid this, that is not particularly helpful:
Many SQL libraries use named parameters when building queries. This results in queries that look like this when they are pulled from the library and sent in the trace:
It seems like it would be possible to translate these named parameters to regular
?
placeholders, and then apply the normal filtering/grouping rules to them in order to reduce cardinality. Named params can be identified by the colon prefix.The text was updated successfully, but these errors were encountered: