Which type of PDO::FETCH_* is the fastest?

Asked

Viewed 123 times

0

Of the ones I know, there are 5 ways to accomplish, but at official documentation is presented about 8 different ways of performing a FETCH_*.

I would like to know, in every way to make one PDO::FETCH_*, which is the fastest to use?

1 answer

3


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 data sets, these results are presented:

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.