simpleQuery method causes too many mysql change db commands

From: Date: Wed, 10 Aug 2005 09:38:08 +0000
Subject: simpleQuery method causes too many mysql change db commands
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-20345@lists.php.net to get a copy of this message
See in output of 'mytop' below that in my production server, 60% of all commands are change db. So I track it down and noticed that in simpleQuery there is database select even though in ::connect method the database is already selected. Can anybody explain why is done this way? Should passing the connection param to mysql_query call be sufficient? function simpleQuery($query) { $ismanip = DB::isManip($query); $this->last_query = $query; $query = $this->modifyQuery($query); /*************** WHY??? if ($this->_db) { if (!@mysql_select_db($this->_db, $this->connection)) { return $this->mysqlRaiseError(DB_ERROR_NODBSELECTED); } } ***************/ Here is the command breakdown from 'mytop' Command Total Pct | Last Pct ------- ----- --- | ---- --- change db 10377634 60% | 85 60% select 3359677 19% | 25 17% admin commands 2902098 16% | 29 20% update 342806 1% | 0 0% insert 167333 0% | 0 0% delete 51233 0% | 0 0% begin 8120 0% | 0 0% commit 8102 0% | 0 0% insert select 7257 0% | 0 0% show status 3576 0% | 1 0% show processlist 1293 0% | 0 0% delete multi 72 0% | 0 0% show tables 50 0% | 0 0% show variables 34 0% | 0 0% set option 29 0% | 0 0% show slave hosts 14 0% | 0 0% show databases 2 0% | 0 0% rollback 1 0% | 0 0% Other production servers I've seen (not using pear db) don't have such a high percentage of database selects. Thanks in advance -Ubaldo

« previous php.pear.general (#20345) next »