Benchmarking PHP–MySQL Communication: A Comparative Study of MySQLi and PDO Under Varying Query Complexity
Abstract
1. Introduction
- MySQLi (procedural style);
- MySQLi (object-oriented style);
- MySQLi with prepared statements;
- PDO with direct query execution;
- PDO with prepared statements (emulated mode);
- PDO with prepared statements (native mode).
- empirically grounded recommendations for choosing a method of connecting to a MySQL database in PHP applications;
- an analysis of the trade-offs between speed, memory efficiency, and flexibility;
- a contribution to the literature through a transparent and replicable testing methodology.
2. Theoretical Background
2.1. Communication Between PHP and the MySQL Database
2.2. The MySQLi Extension: Characteristics and Access Modes
- Procedural style, in which functions are called directly with explicit parameter passing (e.g., mysqli_query($conn, $sql)).
- Object-oriented style, where an instance of the MySQLi class is used (for example, invoking the query method of the $mysqli object, $mysqli->query($sql)), which allows for greater modularity and code readability.
2.3. PDO (PHP Data Objects): An Abstract Database Layer
- Direct query execution, using the query() method, when SQL statements are sent directly to the server;
- Using prepared statements, which can be realized in two modes:
- o
- Emulated mode, where the preparation and evaluation of the statement are performed on the PHP side;
- o
- Native mode, where prepared statements are processed directly on the database side, assuming the driver supports it [2].
2.4. Prepared Statements: Security and Performance Aspects
- Increased security—by eliminating the possibility of SQL injection, because data are not part of the SQL statement itself [3];
- Improved performance—especially in cases of repeated execution of the same query with different values (e.g., in loops).
2.5. Comparative Analysis of Approaches
2.6. Review of Relevant Literature and Industry Validation Examples
- M1 (MySQLi procedural);
- M2 (MySQLi object-oriented);
- M3 (MySQLi prepared statements);
- M4 (PDO query execution);
- M5 (PDO prepared statements—emulated);
- M6 (PDO prepared statements—native).
2.6.1. Industry Validation Examples (Non-Peer-Review)
- EverSQL (2023) [14]: Summarizes comparative outcomes for PDO and MySQLi across different PHP versions on a sizable single-table dataset. The post reports generally small differences between the APIs and emphasizes that performance depends strongly on PHP and MySQL versions.
- Jim Westergren (2016–2017) [15]: Presents timing experiments across PDO (emulated/native) and MySQLi variants, noting that prepared statement behavior is context-dependent and that emulation can alter observed performance.
- Wooptoo (2012) [16]: Reports extensive repetition benchmarks (INSERT, SELECT, UPDATE, DELETE) comparing PDO and MySQLi with and without prepared statements, showing that results vary widely with configuration and workload size.
- USAVPS (2024) [17]: A hosting-provider article aggregating community tests and adding VPS-based trials; it concludes that the choice of API depends more on architectural flexibility and portability needs than on raw speed.
2.6.2. The Need for Systematic Experimental Research
- Different PHP/MySQL versions and configurations affecting internal optimization;
- Diverse database sizes, caching strategies, and repetition counts;
- Distinct implementations of prepared statements (native vs. emulated);
- Divergent focus on metrics such as execution time, memory footprint, or code portability.
- Compare PDO and MySQLi approaches under identical conditions using a moderately sized, well-structured relational dataset (e.g., ClassicModels) suitable for reproducibility;
- Measure execution time with strict variable control and apply statistical validation (e.g., Kruskal–Wallis, Mann–Whitney);
- Include different query categories (simple SELECT, multi-JOIN, GROUP BY/HAVING), with and without prepared statements;
- Take into account the versions of PHP and MySQL to ensure relevance to modern production environments.
3. Research Methodology
3.1. Description of the Experimental Environment
- Operating system: Windows 10 Home 22H2 (64-bit);
- WAMP environment: WampServer 3.3.0 (64-bit), which includes
- o
- Apache 2.4.54.2;
- o
- MySQL 8.0.31;
- o
- PHP 8.0.26;
- o
- phpMyAdmin 5.2.
- Hardware: Intel Core i7-2630QM, 12 GB RAM, 120 GB SSD.
3.2. Defined Query Tests
- MySQLi (procedural);
- MySQLi (object-oriented);
- MySQLi prepared statements;
- PDO (object-oriented);
- PDO prepared statements emulated;
- PDO prepared statements native.
- Full benchmark: includes establishing the connection;
- Isolated execution: only the execution of a previously prepared statement is measured.
3.3. Performance Metrics
- Query execution time (milliseconds (ms));
- Peak memory usage (kilobytes (kB)).
3.4. Description of Test Implementation
| Listing 1. Benchmark function. |
| function benchmark(callable $fn, string $method, int $runs = 200) { $times = []; $memoriesPeak = []; for ($i = 0; $i < $runs; $i++) { gc_collect_cycles(); $start = hrtime(true); $startMem = memory_get_usage(false); $fn(); $time = (hrtime(true) − $start)/1e6;//ms $peakMem = (memory_get_peak_usage(false) − $startMem)/1024;//kB $times[] = $time; $memoriesPeak[] = $peakMem; logResult($method, $time, $peakMem); } $avgTime = round(array_sum($times)/count($times), 3); $avgPeakMem = round(array_sum($memoriesPeak)/count($memoriesPeak), 3); logResult2($method, $avgTime, $avgPeakMem); } Example of a test function with connection included (MySQLi prepared): benchmark(function() use ($host, $user, $pass, $db, $query, $productLine, $minAvg) { $conn = new mysqli($host, $user, $pass, $db); $stmt = $conn->prepare($query); $stmt->bind_param(“si”, $productLine, $minAvg); $stmt->execute(); while ($row = $stmt->get_result()->fetch_assoc()) {} $stmt->close(); $conn->close(); }, “mysqli_prepared”); Example of a test function without connection (PDO prepared): $stmt = $pdo->prepare($query); $stmt->bindParam(‘:status’, $status, PDO::PARAM_STR); benchmark(function() use ($stmt) { $stmt->execute(); while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {} $stmt->closeCursor(); }, “pdo_prepared_static”); |
3.5. Reproducibility
4. Evaluation of the Performance of Database Access Methods
4.1. Experimental Environment
- Average execution time (in milliseconds);
- Peak memory usage (in kilobytes);
- Standard deviation;
- Skewness (asymmetry) and kurtosis (peakedness of the distribution);
- 95% confidence intervals (CI).
4.2. Analysis for a Simple SELECT Query (Connection Outside the Benchmark Test (M1))
4.2.1. Execution-Time Analysis (M1)
- The MySQLi_prepared_static method had the lowest average execution time and one of the smallest variances, indicating speed and consistency.
- Although pdo_prepared_emulated_static did not have the best average time, it showed the smallest variation, which can be useful in latency-sensitive applications.
- All methods had high positive skewness values, indicating occasional slow executions (likely due to external I/O factors or caching).
4.2.2. Memory Usage Analysis (M1)
- MySQLi_prepared_static consistently had the lowest memory consumption, making it the most efficient method in terms of memory.
- Emulated prepared statements in PDO (PDO_prepared_emulated_static) used almost the same amount of memory as PDO_query_static, indicating that emulation does not bring advantages in memory efficiency.
- Skewness values were generally low and positive, indicating a slight asymmetry in memory usage across methods.
4.2.3. Relationship Between Mean and Median Values (M1)
4.2.4. Skewness and Kurtosis (M1)
4.2.5. Confidence Interval (95%)—Time and Memory (M1)
4.2.6. Conclusions of the Descriptive Statistics Analysis for the Simple SELECT Query (M1)
- MySQLi_prepared_static is the fastest and most stable in terms of both time and memory.
- PDO_prepared_static (native): a good compromise—better performance than PDO_query_static, lower memory consumption.
- PDO_prepared_emulated_static:
- o
- More stable time (lowest standard deviation), but
- o
- Almost the same memory consumption as PDO_query_static—emulation clearly does not bring memory efficiency.
- For maximum efficiency and performance accuracy—use the MySQLi prepared approach.
- If PDO is used, native prepared statements should be preferred, and emulated ones avoided when memory consumption is important.
4.2.7. Statistical Analysis of the Performance of Query Execution Methods—Non-Parametric Tests (M1)
- Execution time: H = 51.32, p < 0.000001;
- Memory usage: H = 710.77, p < 0.000001.
- Significant differences:
- o
- MySQLi_object_static–PDO_query_static (p ≈ 0.0009);
- o
- MySQLi_prepared_static–PDO_query_static (p ≈ 0.0071);
- o
- MySQLi_procedural_static–PDO_prepared_static (p ≈ 0.0001);
- o
- MySQLi_procedural_static–PDO_prepared_emulated_static (p ≈ 0.016);
- o
- PDO_prepared_static–PDO_query_static (p ≈ 4.6 × 10−9);
- o
- PDO_prepared_emulated_static–PDO_query_static (p ≈ 4.77 × 10−6).
- No significant difference:
- o
- MySQLi_object_static–MySQLi_prepared_static;
- o
- MySQLi_prepared_static–MySQLi_procedural_static;
- o
- PDO_prepared_static–PDO_prepared_emulated_static;
- o
- PDO_prepared_emulated_static–PDO_prepared_static.
- Almost all pairs of methods show statistically significant differences, except for the following:
- o
- PDO_prepared_static–PDO_prepared_emulated_static;
- o
- PDO_prepared_static–PDO_query_static;
- o
- PDO_prepared_emulated_static–PDO_query_static.
4.2.8. Conclusion for the Simple SELECT Query (Connection Outside the Benchmark Test (M1))
- MySQLi_prepared_static is the fastest and most stable approach, in terms of both time and memory consumption. It is suitable for applications where performance and stability are key;
- The PDO native approach (PDO_prepared_static) represents a good compromise—it offers better performance than PDO_query_static, with lower memory consumption;
- The emulated PDO approach (PDO_prepared_emulated_static) shows stability in execution time (lowest standard deviation) but does not bring savings in memory compared to other PDO methods;
- The normality tests confirm pronounced asymmetry (skewness) and high peakedness of the distribution (kurtosis) for execution time, indicating the presence of outliers—potentially due to external factors, caching, or I/O operations.
- For optimal performance: use MySQLi_prepared_static whenever possible;
- If PDO is used: prefer the PDO_prepared_static (native) approach, and avoid emulation when memory requirements are important;
- For applications with real-world load: additional analysis of outliers is recommended, as the current results show distributions with extreme values that can affect performance in production.
4.3. Analysis of a Simple SELECT Query (Connection Inside the Benchmark Test (M2))
4.3.1. Execution-Time Analysis (M2)
- The method PDO_query achieved the shortest average time, followed by MySQLi_procedural;
- MySQLi_prepared shows a good balance between speed and stability;
- All methods have negative skewness values, indicating a higher frequency of shorter execution times and a smaller number of significantly slower executions.
4.3.2. Analysis of Peak Memory Consumption (M2)
- The MySQLi_procedural method had the lowest average memory consumption;
- The most stable memory consumption was recorded for MySQLi_prepared, with the smallest standard deviation;
- All PDO approaches consume significantly more memory, while the difference between native and emulated prepared statements is not significant.
4.3.3. Relationship Between Mean and Median Values (M2)
4.3.4. Skewness and Kurtosis (M2)
4.3.5. Confidence Intervals (95%) (M2)
- The methods MySQLi_prepared and MySQLi_procedural have the narrowest intervals—indicating high consistency of results.
- PDO methods have wider memory-consumption intervals, indicating greater variability in performance.
4.3.6. Conclusions of the Descriptive Statistics Analysis for the Simple SELECT Query (Connection Inside the Benchmark Test (M2))
- Execution speed: The fastest methods are PDO_query and MySQLi_procedural, albeit with somewhat higher variability;
- Memory efficiency: The lowest consumption is recorded for MySQLi_procedural, while MySQLi_prepared offers the best stability in both aspects;
- PDO prepared methods:
- o
- Native and emulated approaches have almost identical memory consumption;
- o
- The emulated approach does not bring performance advantages either in speed or in memory.
- For maximum predictability and performance stability, it is recommended to use the MySQLi_prepared method;
- If PDO is used, native prepared statements should be preferred, and emulation avoided when memory efficiency is important.
4.3.7. Statistical Analysis of Method Performance—Non-Parametric Tests (M2)
- For execution time: H = 231.83, p < 0.000001;
- For memory usage: H = 945.60, p < 0.000001.
- MySQLi_object and MySQLi_prepared (p = 1);
- PDO_prepared_emulated and PDO_prepared_native (p = 0.48);
- MySQLi_procedural and PDO_query (p = 0.88).
- PDO_prepared_native and PDO_prepared_emulated (p = 1);
- PDO_query and PDO_prepared_emulated (p = 1);
- MySQLi_object and MySQLi_procedural (p = 0.64).
- PDO approaches (PDO_query, prepared_native, prepared_emulated) have consistent and mutually similar results in terms of memory.
- MySQLi_procedural shows the best balance between speed and memory efficiency.
- MySQLi_prepared and PDO_prepared_native stand out for stability but not for the best speed or the lowest memory consumption.
4.3.8. Conclusions of the Analysis for the Simple SELECT Query (Connection Inside the Test (M2))
- Execution speed: The fastest methods are PDO_query and MySQLi_procedural, while the others show somewhat slower execution but often with lower variation;
- Memory consumption: MySQLi_procedural is the most efficient in terms of average memory consumption. However, MySQLi_prepared proved to be the method with the lowest variability in both aspects—speed and memory;
- PDO approaches: Native and emulated prepared statements have almost identical memory consumption. Emulation does not bring any advantages, which is important for design decisions in implementation;
- Distribution characteristics: Negative skewness and low kurtosis for execution time indicate a relatively stable but also “flattened” distribution. Memory consumption shows slight positive asymmetry, particularly for MySQLi methods.
- If the best combination of speed and memory efficiency is sought, MySQLi_procedural represents the most practical choice;
- For applications that require stability and predictability, MySQLi_prepared is recommended;
- PDO native prepared statements are a better choice than emulated ones, but their higher memory consumption in this scenario should be kept in mind.
4.4. Analysis for a SELECT Query with 5 JOINs (Connection Outside the Benchmark Test (M3))
4.4.1. Execution-Time Analysis (M3)
- The fastest method is MySQLi_procedural_static, but with notably high skewness and standard deviation, indicating numerous outliers;
- MySQLi_prepared_static delivers balanced performance—second-lowest average time with the smallest variability;
- The PDO_prepared_static_e method exhibits markedly higher variability (largest std dev and range), indicating unstable performance for emulated prepared statements;
- All methods show high skewness values, pointing to the presence of exceptionally slow executions in a small number of cases.
4.4.2. Peak Memory Analysis (M3)
- MySQLi_procedural_static shows perfectly consistent memory consumption (std dev = 0), suggesting deterministic behavior of the memory allocator for this method;
- The lowest average memory consumption is observed for MySQLi_prepared_static and PDO_prepared_static_n;
- PDO methods (query, prepared_native, prepared_emulated) have slightly higher average memory usage, though the differences are not substantial;
- Skewness values are low and positive, indicating a mildly asymmetric distribution with occasional higher values.
4.4.3. Relationship Between Means and Medians (M3)
4.4.4. Skewness and Kurtosis (M3)
4.4.5. Confidence Intervals (95%) (M3)
- PDO_query_static and MySQLi_prepared_static have the narrowest intervals—indicating very stable execution-time behavior.
- The zero width of the interval for memory in MySQLi_procedural_static confirms its constancy.
4.4.6. Conclusions of the Descriptive Statistics Analysis for SELECT with 5 JOINs (Connection Outside the Benchmark Test (M3))
- The fastest method is MySQLi_procedural_static, but its extreme skewness (8.97) and kurtosis (99.30) indicate a substantial number of outliers, undermining predictability and stability;
- MySQLi_prepared_static emerges as the most stable—second-lowest mean time and the narrowest confidence interval, with low variability and balanced memory usage;
- PDO methods have consistent memory consumption, but emulated PDO prepared statements (PDO_prepared_static_e) exhibit the greatest variability in execution time, indicating unstable performance;
- Execution-time distributions are non-normal for all methods (as confirmed by Shapiro–Wilk and D’Agostino tests), while memory consumption is considerably more stable and symmetric, with mildly negative kurtosis.
- For stable performance on complex SELECT queries with multiple JOINs, use MySQLi_prepared_static;
- Avoid PDO with emulated prepared statements in scenarios requiring temporal consistency;
- MySQLi_procedural_static can be fast but is not reliable—use only if outliers are further filtered in post-processing;
- If PDO is used, native prepared statements are preferable to emulated variants.
4.4.7. Normality Tests and Non-Parametric Tests (M3)
- Execution time: H = 663.7347, p = 0.000000 → Statistically significant differences between methods;
- Peak memory: H = 931.5046, p = 0.000000 → Statistically significant differences between methods;
- MySQLi_prepared_static is significantly faster than PDO_prepared_static_n (p = 1.32 × 10−28) and PDO_query_static (p = 1), while also more stable;
- PDO_prepared_static_e does not differ significantly from PDO_query_static (p ≈ 0.11), confirming prior findings of similarity in performance;
- MySQLi_object_static and MySQLi_procedural_static differ significantly, supporting MySQLi_prepared_static as a balanced alternative.
- MySQLi_prepared_static and PDO_prepared_static_n are significantly more memory-efficient than others (p < 1 × 10−60 for most pairs);
- PDO_prepared_static_e and PDO_query_static are not significantly different in memory (p = 1), implying that emulation offers no benefit here either;
- MySQLi_procedural_static has fully consistent memory (std dev = 0), yet differences relative to other methods remain statistically significant.
4.4.8. Conclusions for SELECT with 5 JOINs (Connection Outside the Test (M3))
- Execution speed: The fastest method is MySQLi_procedural_static, but its extreme variability and presence of outliers (high skewness and kurtosis) substantially reduce reliability. The most stable method in terms of time is MySQLi_prepared_static, which combines a low mean, a narrow confidence interval, and a small standard deviation;
- Memory consumption: MySQLi_prepared_static and PDO_prepared_static_n record the lowest average memory usage. The MySQLi_procedural_static method shows completely constant memory usage, which is likely a consequence of specific implementation details rather than a universal advantage in real-world conditions;
- PDO approaches: PDO methods—especially with emulated prepared statements (PDO_prepared_static_e)—exhibit higher variability in execution time. Emulation brings no advantage in speed or memory, whereas PDO_prepared_static_n shows better and more stable results. Statistical tests confirm that the difference between emulated and native approaches is non-negligible;
- Distributional characteristics: All time measurements deviate from normality, with substantial positive skewness and high kurtosis, indicating the presence of extremely slow executions. By contrast, memory consumption is mostly stable, with moderately positive skewness and negative kurtosis.
- For balanced performance and predictability, MySQLi_prepared_static is the best choice in this scenario;
- PDO with native prepared statements is an acceptable alternative, but one should account for somewhat higher memory usage and lower stability compared with MySQLi approaches;
- PDO with emulated prepared statements should be avoided for demanding queries—it shows the greatest variability without performance benefits;
- MySQLi_procedural_static may be useful in specific cases where speed outweighs stability but is generally not recommended for consistent systems.
4.5. Analysis for a SELECT Query with 5 JOINs (Connection Inside the Benchmark Test (M4))
4.5.1. Execution-Time Analysis (M4)
- The fastest method is PDO_query, with the lowest average time (102.43 ms) and the lowest standard deviation (6.32 ms), indicating stable performance.
- MySQLi_prepared also performs well, balancing speed with a moderate spread of variation.
- The PDO_prepared_e method has the largest range (68.08 ms), suggesting greater instability when using emulated prepared statements.
- All methods have positive skewness values, indicating the occasional presence of slower executions (outliers).
4.5.2. Peak Memory Analysis (M4)
- As in the previous chapter, MySQLi_procedural shows perfectly consistent memory consumption (std dev = 0).
- The highest average memory usage is recorded for the PDO methods, especially PDO_prepared_n and PDO_prepared_e, with values above 1950 kB.
- Skewness values are low and positive, indicating stable, mildly asymmetric memory distributions.
4.5.3. Relationship Between Means and Medians (M4)
4.5.4. Skewness and Kurtosis (M4)
4.5.5. Confidence Intervals (95%) (M4)
- The PDO_query method has the narrowest time CI, confirming its stability.
- MySQLi_procedural is the only method with a zero interval for memory, confirming constancy in that dimension.
- Other methods have approximately equal confidence interval widths for memory.
4.5.6. Conclusions of the Descriptive Statistics Analysis for SELECT with 5 JOINs (Connection Inside the Benchmark Test (M4))
- The most stable execution-time results are achieved by PDO_query, with the lowest standard deviation and the narrowest confidence interval;
- MySQLi_prepared is also competitive, with solid performance and a stable memory profile;
- The PDO prepared (emulated) approach shows greater variability and somewhat lower efficiency, visible in wider time intervals and a larger execution-time range;
- Memory stability is high for MySQLi_procedural, which maintains constant memory consumption across all iterations (std dev = 0);
- Execution-time distributions are slightly asymmetric with outliers present, whereas memory distributions are relatively flat and free of extreme values.
- For applications requiring stability and low latency with multi-JOIN queries, PDO_query and MySQLi_prepared are optimal choices;
- The emulated PDO approach should be avoided when predictable behavior is needed for complex queries;
- In applications where deterministic memory usage is important, MySQLi_procedural shows exceptional consistency.
4.5.7. Normality Tests and Non-Parametric Tests (M4)
- Execution time: H = 149.5773, p = 0.000000 → Statistically significant differences between methods.
- Peak memory: H = 451.2599, p = 0.000000 → Statistically significant differences between methods.
- MySQLi_object, MySQLi_prepared, and MySQLi_procedural do not differ significantly among themselves (p ≈ 1);
- PDO_query and PDO_prepared_n differ significantly from all MySQLi methods (e.g., PDO_query vs. MySQLi_prepared: p = 4.07 × 10−8);
- PDO_prepared_e occupies a middle position—no significant difference relative to the MySQLi methods, but significantly different from PDO_query (p = 2.58 × 10−15) and PDO_prepared_n (p = 0.0039).
- MySQLi_object and MySQLi_prepared do not differ from each other (p = 1), but both differ significantly from all other methods (e.g., relative to MySQLi_procedural: p = 6.6 × 10−33);
- MySQLi_procedural shows extreme differences relative to all methods, indicating drastically different memory consumption;
- PDO_prepared_e and PDO_prepared_n are identical in memory (p = 1), but differ significantly from PDO_query (p = 0.0365) and from all MySQLi methods;
- PDO_query has a memory profile relatively similar to the PDO_prepared methods, but significantly higher than MySQLi_procedural.
4.5.8. Conclusions for SELECT with 5 JOINs (Connection Inside the Test (M4))
- Execution speed:
- o
- The most stable method in terms of time is PDO_query, with the lowest standard deviation, a narrow confidence interval, and the smallest mean execution time. MySQLi_prepared is close in performance, with the added advantage of stability;
- o
- The PDO_prepared_e method shows pronounced variability, with the widest range and higher skewness and kurtosis values, reducing reliability in production settings.
- Memory consumption:
- o
- MySQLi_procedural is the only method with completely constant memory usage (std dev = 0), which may be advantageous in specific cases;
- o
- The lowest average memory consumption is observed with MySQLi_prepared and MySQLi_object, whereas PDO methods generally require more memory.
- PDO approaches:
- o
- PDO_prepared_n (native) shows better stability and efficiency compared with PDO_prepared_e (emulated), as confirmed by post hoc tests;
- o
- Emulating prepared statements in PDO brings no advantage; on the contrary, it increases variability and memory consumption.
- Distributional characteristics:
- o
- Execution-time distributions for all methods deviate from normality and have positive skewness, indicating occasional slow executions (outliers);
- o
- Memory-consumption distributions are flat (negative kurtosis), without extreme values, with moderate positive asymmetry.
- For predictable and fast execution of complex SELECT queries, PDO_query and MySQLi_prepared are the safest choices;
- PDO prepared emulation (PDO_prepared_e) should be avoided in demanding scenarios—it shows the greatest variability without clear benefits;
- MySQLi_procedural is useful in systems where deterministic memory usage is a priority, although it may be slower in some cases;
- PDO native prepared (PDO_prepared_n) is an acceptable alternative, but with somewhat higher memory consumption.
4.6. Analysis for a SELECT Query with HAVING and GROUP BY (Connection Outside the Benchmark Test (M5))
4.6.1. Execution-Time Analysis (M5)
- The smallest mean (87.56 ms) and the lowest variability (std dev 2.14 ms) are recorded by MySQLi_prepared_static, indicating robustness;
- PDO_prepared_static_e shows the greatest instability—its widest range and high skewness indicate the presence of outliers;
- All methods exhibit positive skewness, suggesting occasional slower executions.
4.6.2. Peak Memory Analysis (M5)
- MySQLi_procedural_static has perfectly deterministic memory usage (std dev = 0);
- The lowest average memory consumption is recorded by MySQLi_prepared_static;
- PDO methods consume somewhat more memory, though differences are not dramatic.
4.6.3. Relationship Between Means and Medians (Time and Memory (M5))
- A small gap between mean and median signals balanced, stable distributions;
- A larger gap for PDO_prepared_static_e confirms the presence of outliers.
4.6.4. Skewness and Kurtosis (M5)
4.6.5. Confidence Intervals (95%) (M5)
4.6.6. Conclusions of the Descriptive Statistics Analysis for SELECT with HAVING and GROUP BY (Connection Outside the Benchmark Test (M5))
- MySQLi_prepared_static stands out as the most optimal method for this query type—combining a low mean, low variability, and low memory consumption;
- PDO_prepared_static_e is the least stable and shows greater deviation and outliers, making it less suitable for reliable performance;
- MySQLi_procedural_static is extremely consistent in memory consumption, but that constancy comes with somewhat weaker temporal stability;
- PDO_query_static and PDO_prepared_static_n offer a good balance of performance and memory use, but do not outperform MySQLi_prepared_static.
4.6.7. Normality Tests and Non-Parametric Tests (M5)
- Execution time: H = 370.6310, p = 0.000000 → Statistically significant differences between methods;
- Peak memory: H = 819.3837, p = 0.000000 → Statistically significant differences between methods.
- MySQLi_object_static and PDO_query_static do not differ (p = 1), nor do MySQLi_object_static and MySQLi_prepared_static (p ≈ 0.75);
- MySQLi_procedural_static shows statistically significant differences relative to all other methods (e.g., vs. MySQLi_object_static: p = 3.96 × 10−38);
- PDO_prepared_static_n differs significantly from most methods, including MySQLi_object_static (p = 0.000294), but not from MySQLi_prepared_static (p ≈ 0.31);
- PDO_prepared_static_e occupies a middle position—no significant difference from MySQLi_object_static (p ≈ 0.19), but significantly different from MySQLi_procedural_static (p = 3.70 × 10−25) and PDO_prepared_static_n (p = 1.95 × 10−10).
- MySQLi_object_static and MySQLi_procedural_static do not differ (p = 1), but both differ significantly from MySQLi_prepared_static (p = 5.68 × 10−71 and p = 1.75 × 10−83);
- MySQLi_prepared_static shows pronounced differences relative to all other methods, including PDO approaches (e.g., vs. PDO_query_static: p = 1.83 × 10−59);
- PDO_prepared_static_e and PDO_prepared_static_n do not differ from each other (p = 1), but differ significantly from MySQLi_procedural_static (p = 2.22 × 10−86) and MySQLi_prepared_static;
- PDO_query_static shows moderate differences relative to the PDO_prepared methods (e.g., vs. PDO_prepared_static_e: p ≈ 0.437), but differs significantly from MySQLi_prepared_static and PDO_prepared_static_n.
- MySQLi_procedural_static shows the largest deviation in execution time, signaling lower efficiency of this method in real-world conditions;
- PDO_query_static and MySQLi_object_static exhibit stable and competitive performance, both in time and memory;
- PDO_prepared_static_n and MySQLi_prepared_static have somewhat higher memory overhead, likely due to additional internal structures related to statement preparation;
- PDO_prepared_static_e occupies a middle ground—neither the fastest nor the most memory efficient, but stable in its results.
4.6.8. Conclusions for SELECT with HAVING and GROUP BY (Connection Outside the Benchmark Test (M5))
- Execution speed:
- o
- MySQLi_prepared_static records the lowest mean (87.56 ms) and the smallest standard deviation (2.14 ms), making it the most reliable choice in this scenario.
- o
- PDO_prepared_static_e shows the greatest variability and skewness, indicating outliers and reduced reliability.
- o
- All methods exhibit positive skewness, implying occasional slower executions and, therefore, a lack of complete consistency.
- Memory consumption:
- o
- MySQLi_procedural_static has fully constant memory usage (std dev = 0 kB), indicating maximum determinism.
- o
- MySQLi_prepared_static has the lowest average memory consumption (1452.78 kB).
- o
- PDO methods—especially PDO_query_static and PDO_prepared_static_e—require somewhat more memory, although the differences are relatively moderate.
- Distributional characteristics:
- o
- Execution-time distributions for all methods are asymmetric (positive skewness) and peaked (high kurtosis), particularly for PDO_prepared_static_e, indicating frequent executions near the mean but with rare slower cases.
- o
- Memory distributions are flat (negative kurtosis), implying stable consumption without extreme spikes.
- Statistical significance:
- o
- Kruskal–Wallis tests confirm statistically significant differences among methods for execution time (H = 370.63) and memory (H = 819.38).
- o
- Post hoc analysis identifies that MySQLi_procedural_static differs significantly in time performance from all other methods.
- o
- PDO_prepared_static_e and PDO_prepared_static_n do not differ significantly from each other in memory, but differ from all MySQL methods.
- Recommendations:
- o
- MySQLi_prepared_static is the most reliable and efficient approach for SELECT queries with aggregation when the connection is already established.
- o
- PDO prepared emulation (PDO_prepared_static_e) should be avoided in production settings due to high variability and overhead.
- o
- MySQLi_procedural_static is useful for cases where deterministic memory usage is crucial, but at the cost of weaker time efficiency.
- o
- PDO native approaches (especially PDO_prepared_static_n) are an acceptable alternative where flexibility is required, but they do not reach the stability of MySQLi_prepared_static.
4.7. Analysis for a SELECT Query with HAVING and GROUP BY (Connection Inside the Benchmark Test (M6))
4.7.1. Execution-Time Analysis (M6)
- The smallest mean (24.15 ms) is achieved by PDO_prepared_e, making it the most efficient method.
- The greatest stability is also shown by PDO_prepared_e, with the lowest standard deviation.
- All methods have small positive skewness, indicating occasional slower executions but without pronounced outliers.
4.7.2. Peak Memory Analysis (M6)
- The highest average memory consumption is recorded by PDO_prepared_n (98.68 kB).
- All methods have very similar memory usage and low variation, indicating system stability with respect to memory.
- Skewness values are mildly positive, without extreme values.
4.7.3. Relationship Between Means and Medians (Time and Memory (M6))
4.7.4. Skewness and Kurtosis (M6)
4.7.5. Confidence Intervals (95%) (M6)
4.7.6. Conclusions of the Descriptive Statistics Analysis for SELECT with HAVING and GROUP BY (Connection Inside the Benchmark Test (M6))
- PDO_prepared_e proves to be the most efficient method in terms of execution time and stability, with
- o
- The lowest average execution time (24.15 ms);
- o
- The lowest standard deviation (7.21 ms);
- o
- The smallest confidence interval for time (±1.00 ms).
- PDO_prepared_n records the highest memory consumption, yet remains within reasonably stable bounds.
- MySQLi_procedural and MySQLi_prepared show somewhat higher average execution times but are not significantly worse in the overall picture.
- All methods have stable and similar memory-consumption distributions, with negligible differences.
4.7.7. Normality Tests and Non-Parametric Tests (M6)
- Execution time: H = 10.6846, p = 0.058004
- Peak memory: H = 58.1417, p = 0.000000
- No significant differences among methods—all p-values ≥ 0.15, confirming the Kruskal–Wallis result;
- The lowest p-values are between MySQLi_procedural and PDO_prepared_e (p ≈ 0.16), which is insufficient for a statistically significant conclusion;
- Methods such as PDO_query, MySQLi_object, and MySQLi_prepared showed a high degree of similarity.
- PDO_prepared_n shows a significant difference in memory consumption compared to all MySQLi methods (e.g., vs. MySQLi_object: p = 1.76 × 10−7);
- PDO_prepared_e also differs significantly from MySQLi_object and MySQLi_procedural (p = 0.00034), but not from MySQLi_prepared (p ≈ 0.24);
- MySQLi_prepared differs moderately from PDO_prepared_n (p = 0.0016), but not from the other MySQLi methods;
- PDO_query behaves similarly to PDO_prepared_e, with identical p-values relative to MySQLi_object and MySQLi_procedural.
4.7.8. Conclusions for SELECT with HAVING and GROUP BY (Connection Inside the Benchmark Test (M6))
- Execution speed:
- o
- PDO_prepared_e records the lowest average time (24.15 ms) and the lowest standard deviation (7.21 ms), making it the most efficient and most stable method in this scenario;
- o
- The other methods (PDO_query, MySQLi_object, MySQLi_prepared, etc.) show very similar performance, with no significant differences between them (confirmed by the Kruskal–Wallis test, p = 0.058);
- o
- All methods exhibit low skewness and negative kurtosis, suggesting uniform performance without pronounced outliers.
- Memory consumption:
- o
- PDO_prepared_n records the highest average memory consumption (98.68 kB), significantly higher than all MySQLi methods;
- o
- The other methods show very similar memory consumption and stability, with minimal deviations and low variability;
- o
- Statistical tests confirm significant differences in memory among methods (H = 58.14, p < 0.001).
- Distributional characteristics:
- o
- All methods show flat distributions for both memory and execution time (negative kurtosis), with mildly positive skewness, indicating stable and predictable performance;
- o
- The greatest deviation in time is seen for PDO_prepared_e, but in a positive sense—speed is high, and outliers occur rarely.
- Statistical significance:
- o
- No confirmed significant differences in speed between methods (p = 0.058);
- o
- There is a clear difference in memory consumption—PDO methods, especially PDO_prepared_n, require more resources compared to MySQLi variants.
- Recommendations:
- o
- PDO_prepared_e is the best option when the connection is part of each query—it combines top speed and stability with acceptable memory consumption;
- o
- MySQLi_object and MySQLi_procedural are good choices in resource-constrained environments, as they offer lower memory usage with acceptable performance;
- o
- PDO_prepared_n should be used only when the advantages of native prepared statements are essential, as it comes at the cost of higher memory usage;
- o
- PDO_query and MySQLi_prepared show balanced results and can be a good compromise in applications that require stability without extreme optimizations.
4.8. Summary of Evaluation Results
5. Discussion of Results
5.1. Performance in the Context of Application Scenarios
- Web applications with a high query frequency;
- Data-heavy API endpoints;
- Dynamic pages that load a large number of records.
5.2. Memory Consumption as a Constraining Factor
- Limited RAM (embedded systems, shared hosting);
- Multiple concurrent connections;
- A high frequency of joins and aggregations.
5.3. The Relationship Between Speed and Stability
5.4. Statistical Relevance and Practical Significance
5.5. Contextual Method Recommendation
5.6. Limitations and Opportunities for Extension
- The tests were conducted under controlled conditions—in production systems there may be variables such as network latency, caching, and concurrent access;
- The security dimension (e.g., SQL injection resilience) was not analyzed;
- The tests were performed on a MySQL database; other systems (PostgreSQL, MariaDB) may yield different results;
- The impact of using a connection pool was not considered and may change the performance of in-test connections.
5.7. Scientific Contribution and Novelty of the Study
- Multiple PHP–MySQL access layers (MySQLi and PDO);
- Three categories of prepared statement execution (procedural, object-oriented, native, and emulated modes);
- The impact of query complexity ranging from simple SELECT to multi-JOIN and HAVING operations;
- Two fundamentally different connection-handling strategies (inside vs. outside each request).
6. Conclusions
- PDO proved to be more flexible and suitable for applications that require multi-database support and an object-oriented coding style. In most tests, particularly with simpler SQL operations, PDO methods showed better performance and lower memory consumption, while the PDO_prepared_e method stood out as the most efficient in terms of execution speed and stability, especially in more complex queries and scenarios with dynamic connections;
- MySQLi provides better performance for more complex queries, especially those with multiple JOIN operations and in high-load situations. Its tight coupling with the MySQL protocol and native support for prepared statements contribute to lower memory consumption and efficiency, which makes it suitable for systems with limited resources and high parallelization;
- When the connection is established within each query, differences in speed among methods decrease, while memory consumption becomes the deciding factor in choosing the optimal approach;
- Statistical analyses show that differences in execution time between methods are not always significant (p ≈ 0.058), but differences in memory consumption are clear and statistically significant (p < 0.001);
- Distributional analysis confirms stable performance of all methods without pronounced outliers, which makes them reliable for production use.
- For applications that require support for multiple database types, flexibility, and clearer object-oriented code—PDO is the recommended choice;
- For applications that are strictly tied to MySQL and where maximum speed and efficiency are a priority—MySQLi can deliver better results.
- Investigating the impact of connection pools and persistent connections on performance;
- Evaluating the security aspects of different methods, particularly resistance to SQL injection;
- Extending testing to other DBMSs such as PostgreSQL and MariaDB for better comparability;
- Analyzing the impact of caching, transactions, and concurrent database access in distributed systems.
Supplementary Materials
Author Contributions
Funding
Data Availability Statement
Conflicts of Interest
References
- PHP Manual. MySQLi Prepared Statements. Available online: https://www.php.net/manual/en/mysqli.prepare.php (accessed on 14 September 2025).
- PHP Manual. PDO::ATTR_EMULATE_PREPARES. Available online: https://www.php.net/manual/en/pdo.setattribute.php (accessed on 14 September 2025).
- OWASP Foundation. SQL Injection Prevention Cheat Sheet. Available online: https://cheatsheetseries.owasp.org (accessed on 14 September 2025).
- Sönmez, Y.; Bayat, O.; Altuğlu, T.B.; Duru, A.D. Performance Comparison of PHP-ASP Web Applications via Database Queries. In Proceedings of the ICEMIS’15: Proceedings of the International Conference on Engineering & MIS 2015, Istanbul, Turkey, 24–26 September 2015; ACM: New York, NY, USA, 2015. [Google Scholar] [CrossRef]
- Laaziri, M.; Benmoussa, K.; Khoulji, S.; Kerkeb, M.L. A Comparative study of PHP frameworks performance. Procedia Manuf. 2019, 32, 864–871. [Google Scholar] [CrossRef]
- Salunke, S.V.; Ouda, A. A Performance Benchmark for the PostgreSQL and MySQL Databases. Future Internet 2024, 16, 382. [Google Scholar] [CrossRef]
- Zmaranda, D.R.; Moisi, C.I.; Győrödi, C.A.; Győrödi, R.Ş.; Bandici, L.; Popescu, D.E. An Analysis of the Performance and Configuration Features of MySQL Document Store and Elasticsearch as an Alternative Backend in a Data Replication Solution. Appl. Sci. 2021, 11, 11590. [Google Scholar] [CrossRef]
- Győrödi, C.A.; Dumse-Burescu, D.V.; Győrödi, R.Ş.; Zmaranda, D.R.; Bandici, L.; Popescu, D.E. Performance Impact of Optimization Methods on MySQL Document-Based and Relational Databases. Appl. Sci. 2021, 11, 6794. [Google Scholar] [CrossRef]
- Taipalus, T. Database Management System Performance Comparisons: A Systematic Literature Review. arXiv 2023, arXiv:2301.01095. [Google Scholar] [CrossRef]
- Yuan, Y.; Lu, Y.; Zhu, K.; Huang, H.; Yu, L.; Zhao, J. A Static Detection Method for SQL Injection Vulnerability in PHP Applications Considering MySQLi and PDO. Appl. Sci. 2023, 13, 11763. [Google Scholar] [CrossRef]
- Kamani, M.; Bhardwaj, R.; Singh, P. Performance Study of Various Connectivity of PHP and MySQL Database. Int. J. Creat. Res. Thoughts 2018, 6, 486. [Google Scholar]
- MoldStud. Boost Your PHP Database Performance: How PDO Outperforms MySQLi. 3 July 2025. Available online: https://moldstud.com/articles/p-boost-your-php-database-performance-how-pdo-outperforms-mysqli (accessed on 14 September 2025).
- MoldStud. Understanding Prepared Statements: PDO vs. MySQLi in PHP Development. 7 June 2025. Available online: https://moldstud.com/articles/p-understanding-prepared-statements-pdo-vs-mysqli-in-php-development (accessed on 14 September 2025).
- Dev.to. MySQL vs MySQLi vs PDO: Performance, Difference, Security (Benchmark Comparison). Available online: https://dev.to/mega6382/mysql-vs-mysqli-vs-pdo-performance-benchmark-difference-and-security-comparison-565o (accessed on 17 December 2025).
- Westergren, J. PDO vs. MySQLi Speed Comparison. 2017. Available online: https://www.jimwestergren.com/pdo-versus-mysqli (accessed on 14 September 2025).
- Wooptoo. PDO vs MySQLi Performance Comparison. 2012. Available online: https://wooptoo.com/blog/pdo-vs-mysqli-performance-comparison (accessed on 14 September 2025).
- USAVPS. Performance Comparison Between PDO-MySQL and MySQLi in PHP. 19 March 2024. Available online: https://usavps.com/blog/107127 (accessed on 14 September 2025).
- Starbuck, C. Descriptive Statistics. In The Fundamentals of People Analytics; Springer Nature: London, UK, 2023. [Google Scholar] [CrossRef]
- De Michele, C.; De Bartolo, S. Skewness-Kurtosis: Small Samples and Power-Law Behavior. arXiv 2025, arXiv:2506.16906. [Google Scholar]
- Mukherjee, H.; Bhonge, P. Assessing Skew Normality in Marks Distribution. arXiv 2025. [Google Scholar] [CrossRef]
- Arnastauskaitė, J.; Ruzgas, T.; Bražėnas, B. An Exhaustive Power Comparison of Normality Tests. Mathematics 2021, 9, 788. [Google Scholar] [CrossRef]
- Chicco, D.; Sichenze, A.; Jurman, G. A Simple Guide to the Use of Student’s t-test, Mann-Whitney U test, Chi-squared test, and Kruskal-Wallis Test in Biostatistics. BioData Min. 2025, 18, 56. [Google Scholar] [CrossRef] [PubMed]
- Soetewey, A. Kruskal-Wallis Test, or the Nonparametric Version of the ANOVA. 2022. Available online: https://statsandr.com/blog/kruskal-wallis-test-nonparametric-version-anova/ (accessed on 14 September 2025).






















| Feature | MySQLi | PDO |
|---|---|---|
| Supported DBMS | MySQL only | Multiple databases (MySQL, SQLite, etc.) |
| Programming style | Procedural and OOP | OOP only |
| Prepared statements | Native | Emulated and native |
| Flexibility | Low | High |
| Multi-database support | No | Yes |
| Label | Query Type | Number of JOINs | Clauses |
|---|---|---|---|
| Q1 | Simple SELECT with WHERE and LIMIT | 0 | WHERE, LIMIT |
| Q2 | SELECT with 5 JOINs | 5 | WHERE, LIMIT |
| Q3 | SELECT with 2 JOINs, GROUP BY and HAVING | 2 | WHERE, GROUP BY, HAVING |
| Method | Mean (ms) | Std Dev | Range | Skewness |
|---|---|---|---|---|
| MySQLi_object_static | 4.36 | 0.66 | 4.47 | 3.65 |
| MySQLi_prepared_static | 4.10 | 0.34 | 2.50 | 3.63 |
| MySQLi_procedural_static | 4.39 | 0.64 | 4.87 | 3.13 |
| PDO_query_static | 4.39 | 0.54 | 3.46 | 3.01 |
| PDO_prepared_static | 4.21 | 0.37 | 2.71 | 3.39 |
| PDO_prepared_emulated_static | 4.30 |
| Method | Mean (kB) | Std Dev | Range | Skewness |
|---|---|---|---|---|
| MySQLi_object_static | 51.45 | 8.52 | 16.05 | 0.85 |
| MySQLi_prepared_static | 34.32 | 2.32 | 7.87 | 1.34 |
| MySQLi_procedural_static | 46.52 | 6.02 | 16.05 | 0.85 |
| PDO_query_static | 66.98 | 8.65 | 24.11 | 0.37 |
| PDO_prepared_static | 40.59 | 7.79 | 21.85 | 0.53 |
| PDO_prepared_emulated_static | 65.34 | 8.65 | 24.27 | 0.37 |
| Method | Mean (ms) | Median (ms) | Mean (kB) | Median (kB) |
|---|---|---|---|---|
| MySQLi_object_static | 4.36 | 4.16 | 51.45 | 42.41 |
| MySQLi_prepared_static | 4.10 | 4.02 | 34.32 | 32.87 |
| MySQLi_procedural_static | 4.39 | 4.19 | 46.52 | 42.41 |
| PDO_query_static | 4.39 | 4.24 | 66.98 | 65.70 |
| PDO_prepared_static | 4.21 | 4.12 | 40.59 | 38.48 |
| PDO_prepared_emulated_static | 4.30 | 4.28 | 65.34 | 64.05 |
| Method | Skewness (ms) | Kurtosis (ms) | Skewness (kB) | Kurtosis (kB) |
|---|---|---|---|---|
| MySQLi_object_static | 3.65 | 14.75 | 0.85 | −1.16 |
| MySQLi_prepared_static | 3.63 | 16.09 | 1.34 | 0.39 |
| MySQLi_procedural_static | 3.13 | 12.70 | 0.85 | −1.16 |
| PDO_query_static | 3.01 | 9.38 | 0.37 | −1.39 |
| PDO_prepared_static | 3.39 | 14.74 | 0.53 | −1.33 |
| PDO_prepared_emulated_static | 3.68 | 21.61 | 0.37 | −1.38 |
| Method | CI 95% (Time_ms) | CI 95% (Memory_kB) |
|---|---|---|
| MySQLi_object_static | ~0.091 | ~1.18 |
| MySQLi_prepared_static | ~0.047 | ~0.32 |
| MySQLi_procedural_static | ~0.091 | ~0.84 |
| PDO_query_static | ~0.076 | ~1.20 |
| PDO_prepared_static | ~0.051 | ~1.09 |
| PDO_prepared_emulated_static | ~0.029 | ~1.21 |
| Method | Mean (ms) | Std Dev (ms) | Range (ms) | Skewness |
|---|---|---|---|---|
| MySQLi_object | 22.76 | 9.98 | 33.74 | −0.499 |
| MySQLi_prepared | 21.07 | 10.80 | 33.74 | −0.499 |
| MySQLi_procedural | 19.76 | 11.22 | 34.18 | −0.116 |
| PDO_query | 18.81 | 10.82 | 34.18 | −0.116 |
| PDO_prepared_native | 23.37 | 10.18 | 33.66 | −0.947 |
| PDO_prepared_emulated | 22.59 | 10.47 | 32.39 | −0.792 |
| Method | Mean (kB) | Std Dev (kB) | Range (kB) | Skewness |
|---|---|---|---|---|
| MySQLi_object | 98.56 | 8.65 | 8.27 | 1.270 |
| MySQLi_prepared | 106.69 | 2.50 | 8.27 | 1.270 |
| MySQLi_procedural | 93.34 | 5.96 | 8.27 | 1.270 |
| PDO_query | 114.39 | 8.65 | 24.11 | 0.366 |
| PDO_prepared_native | 114.99 | 8.02 | 22.42 | 0.486 |
| PDO_prepared_emulated | 114.39 | 8.65 | 24.11 | 0.366 |
| Method | Mean (ms) | Median (ms) | Mean (kB) | Median (kB) |
|---|---|---|---|---|
| MySQLi_object | 22.76 | 27.32 | 98.56 | 105.11 |
| MySQLi_prepared | 21.07 | 27.32 | 106.69 | 105.11 |
| MySQLi_procedural | 19.76 | 18.36 | 93.34 | 105.11 |
| PDO_query | 18.81 | 18.36 | 114.39 | 113.11 |
| PDO_prepared_native | 23.37 | 29.83 | 114.99 | 113.11 |
| PDO_prepared_emulated | 22.59 | 29.44 | 114.39 | 113.11 |
| Method | Skewness (ms) | Kurtosis (ms) | Skewness (kB) | Kurtosis (kB) |
|---|---|---|---|---|
| MySQLi_object | −0.499 | −1.520 | 1.270 | 0.163 |
| MySQLi_prepared | −0.499 | −1.520 | 1.270 | 0.163 |
| MySQLi_procedural | −0.116 | −1.713 | 1.270 | 0.163 |
| PDO_query | −0.116 | −1.713 | 0.366 | −1.385 |
| PDO_prepared_native | −0.947 | −0.897 | 0.486 | −1.345 |
| PDO_prepared_emulated | −0.792 | −1.127 | 0.366 | −1.385 |
| Method | CI 95% (Time, ms) | CI 95% (Memory, kB) |
|---|---|---|
| MySQLi_object | 1.51 | 0.35 |
| MySQLi_prepared | 1.51 | 0.35 |
| MySQLi_procedural | 1.51 | 0.35 |
| PDO_query | 1.51 | 1.21 |
| PDO_prepared_native | 1.42 | 1.12 |
| PDO_prepared_emulated | 1.46 | 1.21 |
| Method | Mean (ms) | Std Dev (ms) | Range (ms) | Skewness |
|---|---|---|---|---|
| MySQLi_object_static | 96.56 | 2.77 | 28.14 | 5.32 |
| MySQLi_prepared_static | 97.98 | 1.85 | 11.27 | 2.74 |
| MySQLi_procedural_static | 95.87 | 3.86 | 48.49 | 8.97 |
| PDO_query_static | 98.16 | 1.75 | 12.21 | 2.43 |
| PDO_prepared_static_n | 101.00 | 3.14 | 23.09 | 3.80 |
| PDO_prepared_static_e | 99.76 | 7.01 | 59.68 | 5.90 |
| Method | Mean (kB) | Std Dev (kB) | Range (kB) | Skewness |
|---|---|---|---|---|
| MySQLi_object_static | 1898.48 | 8.52 | 23.77 | 0.39 |
| MySQLi_prepared_static | 1872.56 | 8.65 | 24.11 | 0.37 |
| MySQLi_procedural_static | 1889.45 | 0 | 0 | / |
| PDO_query_static | 1899.20 | 7.20 | 20.08 | 0.66 |
| PDO_prepared_static_n | 1872.54 | 8.65 | 24.52 | 0.37 |
| PDO_prepared_static_e | 1898.31 | 8.01 | 23.91 | 0.49 |
| Method | Mean (ms) | Median (ms) | Mean (kB) | Median (kB) |
|---|---|---|---|---|
| MySQLi_object_static | 96.56 | 95.95 | 1898.48 | 1897.07 |
| MySQLi_prepared_static | 97.98 | 97.61 | 1872.56 | 1871.27 |
| MySQLi_procedural_static | 95.87 | 95.23 | 1889.45 | 1889.45 |
| PDO_query_static | 98.16 | 97.76 | 1899.20 | 1896.48 |
| PDO_prepared_static_n | 101.00 | 100.25 | 1872.54 | 1871.25 |
| PDO_prepared_static_e | 99.76 | 98.31 | 1898.31 | 1896.39 |
| Method | Skewness (ms) | Kurtosis (ms) | Skewness (kB) | Kurtosis (kB) |
|---|---|---|---|---|
| MySQLi_object_static | 5.32 | 40.70 | 0.39 | −1.38 |
| MySQLi_prepared_static | 2.74 | 9.59 | 0.37 | −1.39 |
| MySQLi_procedural_static | 8.97 | 99.30 | / | / |
| PDO_query_static | 2.43 | 8.63 | 0.66 | −1.28 |
| PDO_prepared_static_n | 3.80 | 18.24 | 0.37 | −1.38 |
| PDO_prepared_static_e | 5.90 | 38.76 | 0.49 | −1.33 |
| Method | CI 95% (Time, ms) | CI 95% (Memory, kB) |
|---|---|---|
| MySQLi_object_static | ~0.39 | ~1.19 |
| MySQLi_prepared_static | ~0.26 | ~1.21 |
| MySQLi_procedural_static | ~0.54 | 0 |
| PDO_query_static | ~0.24 | ~0.99 |
| PDO_prepared_static_n | ~0.43 | ~1.21 |
| PDO_prepared_static_e | ~0.97 | ~1.12 |
| Method | Mean (ms) | Std Dev (ms) | Range (ms) | Skewness |
|---|---|---|---|---|
| MySQLi_object | 107.82 | 10.06 | 46.19 | 1.18 |
| MySQLi_prepared | 106.57 | 8.04 | 49.03 | 1.82 |
| MySQLi_procedural | 107.55 | 9.53 | 42.39 | 0.90 |
| PDO_query | 102.43 | 6.32 | 38.36 | 1.30 |
| PDO_prepared_n | 111.05 | 8.04 | 42.44 | 1.25 |
| PDO_prepared_e | 108.73 | 9.45 | 68.08 | 1.80 |
| Method | Mean (kB) | Std Dev (kB) | Range (kB) | Skewness |
|---|---|---|---|---|
| MySQLi_object | 1945.59 | 8.65 | 24.11 | 0.37 |
| MySQLi_prepared | 1945.59 | 8.65 | 24.11 | 0.37 |
| MySQLi_procedural | 1936.30 | 0.00 | 0.00 | / |
| PDO_query | 1947.32 | 6.93 | 19.23 | 0.71 |
| PDO_prepared_n | 1950.47 | 8.65 | 24.11 | 0.37 |
| PDO_prepared_e | 1950.47 | 8.65 | 24.11 | 0.37 |
| Method | Mean (ms) | Median (ms) | Mean (kB) | Median (kB) |
|---|---|---|---|---|
| MySQLi_object | 107.82 | 103.30 | 1945.59 | 1944.30 |
| MySQLi_prepared | 106.57 | 104.38 | 1945.59 | 1944.30 |
| MySQLi_procedural | 107.55 | 104.07 | 1936.30 | 1936.30 |
| PDO_query | 102.43 | 100.32 | 1947.32 | 1944.30 |
| PDO_prepared_n | 111.05 | 108.82 | 1950.47 | 1949.19 |
| PDO_prepared_e | 108.73 | 105.68 | 1950.47 | 1949.19 |
| Method | Skewness (ms) | Kurtosis (ms) | Skewness (kB) | Kurtosis (kB) |
|---|---|---|---|---|
| MySQLi_object | 1.18 | 1.03 | 0.37 | −1.39 |
| MySQLi_prepared | 1.82 | 4.79 | 0.37 | −1.39 |
| MySQLi_procedural | 0.90 | 0.11 | / | / |
| PDO_query | 1.30 | 2.80 | 0.71 | −1.25 |
| PDO_prepared_n | 1.25 | 1.98 | 0.37 | −1.39 |
| PDO_prepared_e | 1.80 | 5.75 | 0.37 | −1.39 |
| Method | CI 95% (Time, ms) | CI 95% (Memory, kB) |
|---|---|---|
| MySQLi_object | ±1.40 | ±1.21 |
| MySQLi_prepared | ±1.12 | ±1.21 |
| MySQLi_procedural | ±1.33 | 0 |
| PDO_query | ±0.88 | ±0.97 |
| PDO_prepared_n | ±1.12 | ±1.21 |
| PDO_prepared_e | ±1.32 | ±1.21 |
| Method | Mean (ms) | Std Dev (ms) | Range (ms) | Skewness |
|---|---|---|---|---|
| MySQLi_object_static | 88.72 | 3.45 | 16.03 | 2.05 |
| MySQLi_prepared_static | 87.56 | 2.14 | 11.27 | 1.89 |
| MySQLi_procedural_static | 88.18 | 3.69 | 18.24 | 2.12 |
| PDO_query_static | 90.07 | 2.65 | 13.45 | 1.76 |
| PDO_prepared_static_n | 89.34 | 2.98 | 15.02 | 1.91 |
| PDO_prepared_static_e | 91.20 | 6.40 | 26.84 | 3.37 |
| Method | Mean (kB) | Std Dev (kB) | Range (kB) | Skewness |
|---|---|---|---|---|
| MySQLi_object_static | 1467.21 | 6.24 | 18.90 | 0.41 |
| MySQLi_prepared_static | 1452.78 | 7.15 | 21.33 | 0.44 |
| MySQLi_procedural_static | 1461.52 | 0.00 | 0.00 | — |
| PDO_query_static | 1480.37 | 6.93 | 20.44 | 0.53 |
| PDO_prepared_static_n | 1455.88 | 6.20 | 17.61 | 0.39 |
| PDO_prepared_static_e | 1479.87 | 7.44 | 21.84 | 0.50 |
| Method | Mean (ms) | Median (ms) | Mean (kB) | Median (kB) |
|---|---|---|---|---|
| MySQLi_object_static | 88.72 | 87.90 | 1467.21 | 1465.89 |
| MySQLi_prepared_static | 87.56 | 87.13 | 1452.78 | 1451.11 |
| MySQLi_procedural_static | 88.18 | 87.56 | 1461.52 | 1461.52 |
| PDO_query_static | 90.07 | 89.44 | 1480.37 | 1478.65 |
| PDO_prepared_static_n | 89.34 | 88.71 | 1455.88 | 1454.76 |
| PDO_prepared_static_e | 91.20 | 89.63 | 1479.87 | 1478.14 |
| Method | Skewness (ms) | Kurtosis (ms) | Skewness (kB) | Kurtosis (kB) |
|---|---|---|---|---|
| MySQLi_object_static | 2.05 | 6.14 | 0.41 | −1.31 |
| MySQLi_prepared_static | 1.89 | 5.38 | 0.44 | −1.28 |
| MySQLi_procedural_static | 2.12 | 6.85 | — | — |
| PDO_query_static | 1.76 | 4.77 | 0.53 | −1.20 |
| PDO_prepared_static_n | 1.91 | 5.00 | 0.39 | −1.35 |
| PDO_prepared_static_e | 3.37 | 11.12 | 0.50 | −1.29 |
| Method | CI 95% (Time, ms) | CI 95% (Memory, kB) |
|---|---|---|
| MySQLi_object_static | ±0.48 | ±1.14 |
| MySQLi_prepared_static | ±0.32 | ±1.17 |
| MySQLi_procedural_static | ±0.54 | 0 |
| PDO_query_static | ±0.39 | ±1.13 |
| PDO_prepared_static_n | ±0.43 | ±1.11 |
| PDO_prepared_static_e | ±0.71 | ±1.21 |
| Method | Mean (ms) | Std Dev (ms) | Range (ms) | Skewness |
|---|---|---|---|---|
| MySQLi_object | 25.21 | 7.65 | 34.46 | 0.27 |
| MySQLi_prepared | 26.13 | 7.45 | 31.49 | 0.14 |
| MySQLi_procedural | 26.35 | 7.94 | 33.87 | 0.26 |
| PDO_query | 26.09 | 7.58 | 32.18 | 0.08 |
| PDO_prepared_n | 25.90 | 7.45 | 25.70 | 0.05 |
| PDO_prepared_e | 24.15 | 7.21 | 26.73 | 0.43 |
| Method | Mean (kB) | Std Dev (kB) | Range (kB) | Skewness |
|---|---|---|---|---|
| MySQLi_object | 97.38 | 8.65 | 24.11 | 0.37 |
| MySQLi_prepared | 97.55 | 8.47 | 23.63 | 0.40 |
| MySQLi_procedural | 97.38 | 8.65 | 24.11 | 0.37 |
| PDO_query | 97.86 | 8.65 | 24.11 | 0.37 |
| PDO_prepared_n | 98.68 | 7.79 | 21.78 | 0.53 |
| PDO_prepared_e | 97.86 | 8.65 | 24.11 | 0.37 |
| Method | Mean (ms) | Median (ms) | Mean (kB) | Median (kB) |
|---|---|---|---|---|
| MySQLi_object | 25.21 | 28.62 | 97.38 | 96.09 |
| MySQLi_prepared | 26.13 | 29.36 | 97.55 | 96.09 |
| MySQLi_procedural | 26.35 | 29.19 | 97.38 | 96.09 |
| PDO_query | 26.09 | 29.39 | 97.86 | 96.57 |
| PDO_prepared_n | 25.90 | 29.15 | 98.68 | 96.57 |
| PDO_prepared_e | 24.15 | 21.77 | 97.86 | 96.57 |
| Method | Skewness (ms) | Kurtosis (ms) | Skewness (kB) | Kurtosis (kB) |
|---|---|---|---|---|
| MySQLi_object | 0.27 | −0.68 | 0.37 | −1.39 |
| MySQLi_prepared | 0.14 | −0.74 | 0.40 | −1.37 |
| MySQLi_procedural | 0.26 | −0.56 | 0.37 | −1.39 |
| PDO_query | 0.08 | −0.83 | 0.37 | −1.39 |
| PDO_prepared_n | 0.05 | −1.22 | 0.53 | −1.33 |
| PDO_prepared_e | 0.43 | −1.16 | 0.37 | −1.39 |
| Method | CI 95% (Time, ms) | CI 95% (Memory, kB) |
|---|---|---|
| MySQLi_object | ±1.07 | ±1.21 |
| MySQLi_prepared | ±1.04 | ±1.18 |
| MySQLi_procedural | ±1.11 | ±1.21 |
| PDO_query | ±1.06 | ±1.21 |
| PDO_prepared_n | ±1.03 | ±1.09 |
| PDO_prepared_e | ±1.00 | ±1.21 |
| Application Context | Recommended Method | Rationale |
|---|---|---|
| REST API with frequent connections | PDO_prepared_e | Fastest and most stable, with acceptable memory overhead |
| Resource-constrained system | MySQLi_object/procedural | Lowest memory consumption |
| Application with demanding JOIN/HAVING | PDO_query or prepared_e | Better handling of complex queries |
| High degree of parallelism | Avoid PDO_prepared_n | Higher memory consumption may overwhelm the system |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2025 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license.
Share and Cite
Andrijević, N.; Lovreković, Z.; Salkić, H.; Šarčević, Đ.; Perišić, J. Benchmarking PHP–MySQL Communication: A Comparative Study of MySQLi and PDO Under Varying Query Complexity. Electronics 2026, 15, 21. https://doi.org/10.3390/electronics15010021
Andrijević N, Lovreković Z, Salkić H, Šarčević Đ, Perišić J. Benchmarking PHP–MySQL Communication: A Comparative Study of MySQLi and PDO Under Varying Query Complexity. Electronics. 2026; 15(1):21. https://doi.org/10.3390/electronics15010021
Chicago/Turabian StyleAndrijević, Nebojša, Zoran Lovreković, Hadžib Salkić, Đorđe Šarčević, and Jasmina Perišić. 2026. "Benchmarking PHP–MySQL Communication: A Comparative Study of MySQLi and PDO Under Varying Query Complexity" Electronics 15, no. 1: 21. https://doi.org/10.3390/electronics15010021
APA StyleAndrijević, N., Lovreković, Z., Salkić, H., Šarčević, Đ., & Perišić, J. (2026). Benchmarking PHP–MySQL Communication: A Comparative Study of MySQLi and PDO Under Varying Query Complexity. Electronics, 15(1), 21. https://doi.org/10.3390/electronics15010021

