$tmp = <<EOF;
SELECT SQL_CALC_FOUND_ROWS
*
FROM
my_table
ORDER BY
date ASC
LIMIT 0, 999999999
EOF
$sth = &returnQuery($DBH, $tmp);
for ($i = 0; $row = $sth->fetchrow_hashref; $i++) {
if ($i && ($i % 2000) == 0) {
print STDOUT "\tSleeping after $i\n";
sleep 2;
}
}
$sth->finish;
print STDOUT "Number of rows operated on = $i\n";
$sth = &returnQuery($DBH, "SELECT FOUND_ROWS()");
@cnt = $sth->fetchrow_array;
$sth->finish;
print STDOUT "returned rows = $cnt[0]\n";
# ./copyDB
Sleeping after 2000
Sleeping after 4000
Sleeping after 6000
Sleeping after 8000
Sleeping after 10000
[...]
Sleeping after 344000
Sleeping after 346000
Sleeping after 348000
Number of rows operated on = 348690
returned rows = 279260
| Subject | Written By | Posted |
|---|---|---|
| SQL_CALC_FOUND_ROWS / found_rows() vs loop counter | 7 reeds | 07/18/2012 10:46AM |
Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.