LoginSignup
0
0

PHP 8.3でprepared statementのパフォーマンス測定

Posted at

概要

その昔,PHPでPDOのprepared statementの数が多くなるとパフォーマンスが劣化するという問題があったらしい.

現在のPHPではどうなのか計測してみました.

計測

計測に使用したコードは以下で紹介されているコードをそのまま使用させていただきました.
https://qiita.com/kmotoki/items/7a0df427c8c2217ebbb4

検証環境

  • ローカルマシン:M1 MacBook Pro
  • Docker
    • PHP 8.3
    • MySQL 8.4

計測結果

bulk count emulate prepare use prepare
2 1.8224699258804 1.6240870475769
4 0.91341543197632 0.8638001203537
8 0.57537820339203 0.51411798000336
16 0.39952325820923 0.34663615226746
32 0.31264271736145 0.26628122329712
64 0.26280272006989 0.22010819911957
128 0.24218599796295 0.21109230518341
256 0.22658925056458 0.19329233169556
512 0.21807780265808 0.18028399944305
1024 0.21493134498596 0.18895649909973
2048 0.21120524406433 0.17133178710937
4096 0.20003170967102 0.17415330410004
8192 0.20919830799103 0.18049108982086
16384 0.25638961791992 0.19883470535278
32768 0.22561557292938 0.23696279525757

PHP 5.3であったようなbulk countが1024から劣化している様子もなくuse prepareの方が、パフォーマンスが出ていることがわかりました.

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0