I've just been wondering after looking at my PHPMyAdmin stats if the mysql_select_db command is actually required in PHP?
I have a number of databases on my main site, some containing just three or four tables and some containing hundreds. Many of my queries use joins between databases and tables and I have always ensured that I specify the database/table/field name in every query to avoid headaches when using joins.
The original mysql_select_db() is still in my database class and selects the 'main' database, but I'm wondering if this is even required, judging by the millions of 'Change Database' queries in the PHPMyAdmin stats I assume that mysql_select_db() physically executes a query to select the database, but seeing as I specify all the database names in my queries is this a wasted query? Should I keep it out or are there any advantages to using the statement?
I was also wondering if there is any real overhead when using joins between databases? As far as I can see from the server's point of view it's doing the exact same number of disk seeks, reads and I can't imagine it'd be any faster if only using one database... but I'm just wanting confirmation from some PHP/MySQL users with more experience...
PHP mysql_select_db - to use or not to use
Moderator: General Moderators