I'm building a Go-based system, with MariaDB as the storage back-end. As the responses from MariaDB/MySQL are the slowest part of the whole application I was wondering a specific thing;
Does the field order in a query matter? Say I have this simpler query (but might be much bigger):
SELECT u.*, cu.FirstName, cu.Surname, uu.FirstName, uu.Surname FROM UserContact u LEFT JOIN User cu ON cu.ID = u.CreatedByID LEFT JOIN User uu ON uu.ID = u.UpdatedByID WHERE u.UserID = ?
u.* be faster before or after the custom fields? Or would the query optimiser tweak it correctly?
It might be trivial speed differentials, but I really care about speed, and as a SQL query easily has up to 1ms response time in my app's requests that normally are only a few microseconds themselves; every tweak in the usage of the SQL queries might be a big help in the overall performance of the system. I'm already buffering a lot of queried data with (in)validated cache, but sometimes in the back-end still need to run custom logic.
I can't test the performance in a Go benchmark at the moment, as in the latest macOS High Sierra the whole OS kernel panics on a filesystem crash if the
mysqld gets called too excessively.