1# Setup – insert(), insertMulti(), insertBulk(), get() – Speed #3
decMuc
announced in
Compare & Tests
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
1# Setup – insert(), insertMulti(), insertBulk(), get() – Performance Comparison
The script 01_setupCompareTest.php provides a consistent test setup to compare the performance of:
PDOdb → github.com/decMuc/PDOdb
ThingEngineer's MysqliDb → github.com/ThingEngineer/PHP-MySQLi-Database-Class
What this test does:
Creates three MySQL tables: test_user, test_orders, and test_payment_options
Generates 6,000 realistic user records (names, emails, dates, passwords, etc.)
Inserts one admin user per engine to measure single insert speed
Performs:
insertMulti() with 1,999 users (PDOdb and ThingEngineer)
insertBulk() with 1,999 users (PDOdb only)
Reads user data in fair 6,000-row blocks
Inserts orders and payment options based on the read results
Visualizes all benchmark results using Bootstrap and Chart.js
Performance & Fairness
In our tests, PDOdb often performed faster – but we want to be careful with that conclusion.
Yes, in most runs PDOdb had the edge, especially in bulk operations.
However, it’s worth noting:
ThingEngineer's MysqliDb is currently always tested last
→ which may influence runtime due to server-side caching or background I/O
Tests were run on a live server that also hosts production traffic
→ which may cause unpredictable CPU or disk usage peaks
We intentionally shuffled test order in some runs
→ and PDOdb still usually came out ahead – but not always
That said, we don't intend to discredit ThingEngineer's library.
In fact, I've personally used it since it first appeared on GitHub and still appreciate its simplicity and stability.
Why this matters
This setup is not meant to be a scientific benchmark – it’s the starting point for a long-term test series, where we want to:
highlight differences in API design
explore advanced features
analyze query building, joins, and subqueries
and eventually detect edge cases or inconsistencies
Yes – insertBulk() in PDOdb is significantly faster than insertMulti()
(both compared to insertMulti() in PDOdb and in ThingEngineer's library).
But that’s not a trick – it’s simply a result of how native PDO allows efficient construction of large insert statements.
ThingEngineer's MysqliDb does not support insertBulk() because the MySQLi extension doesn’t provide a clean way to implement it with bound parameters.
Summary
Take the numbers with a grain of salt – this is a practical test, not an academic one.
But one thing is clear: both libraries are solid. And this setup gives us a way to explore them side by side – transparently and reproducibly.
Motivation – Not Competition
These tests are not intended to start a competition.
They exist purely to highlight the differences – and in later test cases (some already done but not yet published), those differences become very noticeable.
This comparison matters to me personally, because Thing's MysqliDb is still used in many of my own projects.
My PDOdb class is meant to replace it – not because I dislike it, but because I’ve run into its limits more and more over the years.
So it's important to me to identify weaknesses and fix known issues before committing to a full switch.
Yes, some may say "rewriting an existing library isn't hard" – and to some extent, they're right.
No, I didn’t reinvent the wheel.
But making something better, more secure, and future-ready without losing the elegance of the original is far from trivial.
Thing's MysqliDb has always had a unique strength: a flat, intuitive, and incredibly practical API.
To this day, I haven’t found another PHP library that matches it in terms of simplicity, power, and flexibility – all at once.
But the reality is: it’s barely maintained anymore.
And just because a sloppy or unsafe query eventually gets rejected by MySQL doesn't mean the library should have passed it through in the first place.
Other databases are often far more strict and would never allow some of these constructs to slip through –
and that’s exactly why this kind of validation belongs in the library, not left to the database engine.
Full Test Script
The test script that produces the full output shown above is available here:
01_setupCompareTest.php
It generates all benchmark data, database tables, and this visual result:

Beta Was this translation helpful? Give feedback.
All reactions