note 53294 deleted from function.ocibindbyname by tony2001

From: Date: Tue, 02 Aug 2005 08:42:14 +0000
Subject: note 53294 deleted from function.ocibindbyname by tony2001
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-92932@lists.php.net to get a copy of this message
Note Submitter: sergei at gmx dot net ---- beware! ocibindbyname can significantly decrease your script performance. When fetching large select statements any useless ocibindbyname will make your script re-parse the query after each row fetched from the database in a loop to refresh the binded variable. Get rid of all ocibindbyname calls in your functions if they're not really needed. Here's a simple example: $sql = 'SELECT field1,field2,field3,field4,field5 FROM images WHERE field6='.$somevar; $stmt = OCIParse($oraConn, $sql); $exec = OCIExecute($stmt,OCI_COMMIT_ON_SUCCESS); while(OCIFetchInto($stmt, $row, 'OCI_NUM')) $array[]=$row; OCIFreeStatement($stmt); The example above will take only 6 seconds to fetch 8 000 from my database. And the example below will take 44(!) seconds to do the same thing: $sql = 'SELECT field1,field2,field3,field4,field5 FROM images WHERE field6=:field6'; $stmt = OCIParse($oraConn, $sql); OCIBindByName(':field6',$somevar) $exec = OCIExecute($stmt,OCI_COMMIT_ON_SUCCESS); while(OCIFetchInto($stmt, $row, 'OCI_NUM')) $array[]=$row; OCIFreeStatement($stmt); As you can see in this case OCIBindByName is not needed at all, so getting rid of this function wherever it's possible can lead to more than 7x performance increase.

« previous php.notes (#92932) next »