I help maintain a program that is essentially a read-only friendly interface for a large and complex MySQL database - the program creates special SELECT queries from the user's login, sends queries to the database, receives the results, processes them and displays them well to the user.
I would like to add some form of reasonable / heuristic prediction for the expected performance of the constructed query - sometimes users inadvertently make queries that will inevitably take a very long time (because they will return huge result sets or because they “go against the grain” of how the database is indexed ), and I would like to show the user some "somewhat reliable" information / guess how long the request will take. It doesn’t have to be perfect if it doesn’t become so bad and often because of the fuss with reality that it causes the effect of a “wail of the wolf” when users learn to ignore it ;-) Based on this information, the user can decide to go for coffee (if the score is 5-10 minutes), go to dinner (if it’s 30-60 minutes), kill the request and try something else (perhaps more stringent restrictions on the information they request), etc. etc.
I am not very familiar with the MySQL EXPLAIN statement - I see a lot of information about how to use it to optimize a query or DB schema, indexing, etc., but not much about how to use it for my more limited purpose - just make a forecast, taking the database as the given one (of course, if the forecasts are reliable enough, I can eventually switch to their use and choose between alternative forms that the request may require, but, what for the future: at the moment, I would very happy just to to show performance for users for the above purposes).
Any pointers ...?
mysql sql-execution-plan
Alex Martelli Apr 25 '09 at 19:00 2009-04-25 19:00
source share