1.2.451. Fetch One Row Format¶
When reading results with ext/Sqlite3, it is recommended to explicitly request SQLITE3_NUM
or SQLITE3_ASSOC
, while avoiding the default value and SQLITE3_BOTH
.
This is a micro-optimisation. The difference may be visible with 200k rows fetches, and measurable with 10k.
<?php
$res = $database->query($query);
// Fastest version, but less readable
$row = $res->fetchArray(\SQLITE3_NUM);
// Almost the fastest version, and more readable
$row = $res->fetchArray(\SQLITE3_ASSOC);
// Default version. Quite slow
$row = $res->fetchArray();
// Worse case
$row = $res->fetchArray(\SQLITE3_BOTH);
?>
1.2.451.1. Connex PHP features¶
1.2.451.1.1. Suggestions¶
Specify the result format when reading rows from a Sqlite3 database
1.2.451.1.2. Specs¶
Short name |
Performances/FetchOneRowFormat |
Rulesets |
|
Exakat since |
0.9.6 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Instant (5 mins) |
Precision |
High |
Available in |