Re: cvs: php4 /pear/DB oci8.php
| From: | Tomas V.V.Cox | Date: | Sun, 06 Jan 2002 16:21:19 +0000 |
| Subject: | Re: cvs: php4 /pear/DB oci8.php | ||
| References: | 1 2 | Groups: | php.pear.cvs |
| Request: | Send a blank email to pear-cvs+get-1856@lists.php.net to get a copy of this message | ||
"Thies C. Arntzen" wrote:
>
> On Sun, Jan 06, 2002 at 04:36:33AM -0000, Thomas V.V.Cox wrote:
> > cox Sat Jan 5 23:36:33 2002 EDT
> >
> > Modified files:
> > /php4/pear/DB oci8.php
> > Log:
> > - use count(*) instead of count(a, b)
>
> have you done some benchmarks on this? i believe that
> count(primary_key) will be the fastest and count(*) the
> slowest way of geting counts from oracle.
>
> tc
Bench details
---------------
50.000 rows on Oracle 8.1.5, PHP 4.1.0, P233
Results (the better of three)
-----------------------------
0.039767 count(*)
0.061140 count(a) (a is not primary key)
0.061591 count(a) (a is primary key)
Test script to insert data
--------------------------
$test_mktable_query = "CREATE TABLE phptest
(a INTEGER NOT NULL PRIMARY KEY,
b VARCHAR(40), c VARCHAR(255), d VARCHAR(20))";
$dbh->query($test_mktable_query);
for ($i = 0; $i < 50000; $i++) {
$dbh->query("INSERT INTO phptest VALUES
($i, 'bing $i', 'This $i is a test',
'1999-$i-21')");
}
Test script to count
--------------------
$timer = new Benchmark_Timer;
$timer->start();
print_r($dbh->getOne('select count(a) from phptest'));
$timer->stop();
print_r($timer->getProfiling());
Tomas V.V.Cox