I want to optimize some MySQL queries.
I'm using knex in my app to construct queries. Using toSQL()
, I'm able to get SQL in a format like this:
{
sql: 'SELECT * FROM Table WHERE id = ?',
bindings: [1]
}
My question is what's the best way to go about optimizing these queries? If I copy the sql into the command line, for use with EXPLAIN
, I need a way to bind the parameters. How can I achieve this?
Or alternatively, are there any better tools than using the MySQL shell to examine the optimizer's query plan?
EDIT: I just ended up copying the query into a text editor and supplying all the parameter bindings manually.