Add a function for optimizer hint queries?
https://dev.mysql.com/doc/refman/8.0/en/optimizer-hints.html
Add a function for optimizer hint queries?
I don't think I can do query.select('/*+ INDEX(table_alias foreign_key) */') or it would add a comma after it.
What API do you like for this? For now I'm probably doing a find/replace in my own code.
Can you not put them into the select argument in the same string as a column?
q.select('/*+ NO_RANGE_OPTIMIZATION(t3 PRIMARY, f2_idx) */ f1').from('t3')
q.select('/*+ BKA(t1) NO_BKA(t2) */ *').from('t2')
(from examples in Optimizer Hints)
It's possible, but depending on the surrounding code, it's easier to just find/replace the final string.
Ah, I see. That makes sense. Maybe adding something like this
selectComment: addToClause(clauses, `select`, comment),
after this line: https://github.com/TehShrike/sql-concat/blob/9272e7338c76c95e4d7cead1cd2c28778465c863/query-object.js#L13
where comment is a new clause handler something like this:
const comment = (...comments) => ({
sql: '/* ' + comments.join(' */ /* ') + ' */',
values: [],
joinedBy: ' ',
})
?
oh no, they're not normal comments, I see that important + now. So it would be selectOptimizerHint instead of selectComment.
And the placement in the query is important. Right after SELECT and before any columns are listed.