As far as I know, there are 5 ways to do it, but the official documentation is displayed about 8 different ways to make a FETCH_*
.
I would like to know, of all the ways to PDO::FETCH_*
, which is the fastest to use?
As far as I know, there are 5 ways to do it, but the official documentation is displayed about 8 different ways to make a FETCH_*
.
I would like to know, of all the ways to PDO::FETCH_*
, which is the fastest to use?
There is a script that does a speed test: Benchmark Script .
I suggest you run this benchmark on your own server, however, this is a typical result in my configuration for single line results:
PDO::FETCH_ASSOC - 936 ms
PDO::FETCH_BOTH - 948 ms
PDO::FETCH_NUM - 1,184 ms
PDO::FETCH_OBJ - 1,272 ms
PDO::FETCH_LAZY - 1,276 ms
For large datasets, these results are displayed:
PDO::FETCH_LAZY - 5,490 ms
PDO::FETCH_NUM - 8,818 ms
PDO::FETCH_ASSOC- 10,220 ms
PDO::FETCH_BOTH - 11,359 ms
PDO::FETCH_OBJ - 14,027 ms