I have a problem I've been scratching my head over for the past couple of months. I have tens of thousands of MySQL databases on the same server, all with the same schema. I want to be able to query across all of them and get a list of results. Currently, I am using a PHP script to loop through every database and execute the query on each one. Sometimes this can take a very long time (10+ minutes) so it's obviously not the best solution.
Here's an example of what I would like to do:
SELECT something FROM db_prefix_*.tablename WHERE something = 1;
... and have it return one set of results, db_prefix_* being the name of the database.
Does anything like this exist or am I dreaming?
This problem might get more complicated as I will be moving these databases to multiple servers but I will cross that road when I get there.