note 63440 added to function.odbc-fetch-row

From: Date: Wed, 22 Mar 2006 13:50:30 +0000
Subject: note 63440 added to function.odbc-fetch-row
Groups: php.notes 
Request: Send a blank email to php-notes+get-106256@lists.php.net to get a copy of this message
I see many here try to iterate to emulate tis missing functionality. I benchmarked the performance on my PentiumM 1.6G on Excel table with 1100 rows and 2 field records and got 82ms time to retrieve number of rows using iteration through all of them, but only 7ms to execute the SQL statement. In this case of thousadn(s) of rows, it is probably faster to have the database calculate rows. Here is different algorithm for calculating the number of rows, which does not iterate through all of them, just uses interval splitting algorithm, and number of iterations is log2(n), where n is total number of rows in the result. The below algorithm in the case above (Excel table, 1100 rows 2 fields) took 10ms to calculate: for($lo=0,$hi=1000000; $lo<$hi; ) { $num = (int)(($hi+$lo) / 2); if(odbc_fetch_row($this->Result, $num)) $lo = $num + 1; else $hi = $num - 1; } ---- Server IP: 216.235.15.211 Probable Submitter: 24.36.119.186 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.odbc-fetch-row.php Edit -- http://master.php.net/note/edit/63440 Del: integrated -- http://master.php.net/note/delete/63440/integrated Del: useless -- http://master.php.net/note/delete/63440/useless Del: bad code -- http://master.php.net/note/delete/63440/bad+code Del: spam -- http://master.php.net/note/delete/63440/spam Del: non-english -- http://master.php.net/note/delete/63440/non-english Del: in docs -- http://master.php.net/note/delete/63440/in+docs Del: other reasons-- http://master.php.net/note/delete/63440 Reject -- http://master.php.net/note/reject/63440 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#106256) next »