GetArray vs FetchRow vs MoveNext in Database Queries

In the core source it appears that GetArray and FetchRow are used interchangeably and I was curious as to which was faster and if MoveNext could be a further improvement on speed.

I ran two tests.
1. 1000 repetitions of select statements to the AttributeValues table which contained 256 records.
2. 100 repetitions of select statements to the adodb_logsql table which contained 4,299 records.

The code below if for the first test. In the second test I changed the $reps value from 1000 to 100 and edited the select statement to use adodb_logsql instead of AttributeValues.

Output csv files are attached.

function get_array(&$db) {
   $res = $db->Execute('select * from AttributeValues');
   $arr = $res->GetArray();
   foreach($arr as $rs) {
function fetch_row(&$db) {
   $res = $db->Execute('select * from AttributeValues');
   while($rs = $res->fetchRow()) {
function move_next(&$db) {

Results (Avg: Average, Med: Median)

1000 repetitions with AttributeValues Table
GetArray Avg: 0.0020289287
GetArray Med: 0.0015950203
FetchRow Avg: 0.0016860282
FetchRow Med: 0.0014758110
MoveNext Avg: 0.0016227308
MoveNext Med: 0.0012609959

100 repetitions with adodb_logsql
GetArray Avg: 0.0656225826
GetArray Med: 0.0669651031
FetchRow Avg: 0.0539252903
FetchRow Med: 0.0534820557
MoveNext Avg: 0.0499147189
MoveNext Med: 0.0500249863

2 Attachments

View Replies:
Mnkras replied on at Permalink Reply
looks like fetchrow is better, good thing that's what I use ;)
mkly replied on at Permalink Reply
I was wondering if MoveNext would be an improvement. But the difference seems pretty small.