To try to make this as realistic as possible, I took an actual page from a
website and made it portable across both MySQL and Postgres. This basically
meant replacing all mysql_query() calls with pg_exec(). This page involves
a lot of selects and joins, as probably most pages on a typical website do.
Once the test page was up and debugged, I then ran "ab", the "Apache Benchmarking"
utility, from my workstation across my 100-mbit LAN to the quad-xeon machine. To
get an idea of scalability under load, I varied the "concurrent connections"
on ab from 10-120, while leaving the number of page views steady at 1000.
To more closely simulate real-world use, I set up a random-number generator in
the script that inserts a row into the database on 10% of the page views. My
own numbers on PHPBuilder show that about 10% of all pages in the discussion
forums are for posting new messages.
Further, as mentioned above, I used real data from a production database. You
can't get a whole lot more realistic than this scenario.
The most interesting thing about my test results was to see how much of a load
Postgres could withstand before giving any errors. In fact, Postgres seemed to
scale 3 times higher than MySQL before giving any errors at all. MySQL
begins collapsing at about 40-50 concurrent connections, whereas Postgres
handily scaled to 120 before balking. My guess is, that Postgres could have gone
far past 120 connections with enough memory and CPU.
On the surface, this can appear to be a huge win for Postgres, but if you
look at the results in more detail, you'll see that Postgres took up to 2-3
times longer to generate each page, so it needs to scale 2-3 times higher
just to break even with MySQL. So in terms of max numbers of pages generated
concurrently without giving errors, it's pretty much a dead heat between
the two databases. In terms of generating one page at a time, MySQL does it
up to 2-3 times faster.
Another interesting point was that MySQL crumbles faster in the "10%
insert" test described above. Research reveals that MySQL locks the entire
table when an insert occurs, while Postgres has a pretty nifty "better than
row-level locking" feature. This difference quickly causes MySQL to pile up concurrent
connections and thus collapse. The same is true if you are doing a large select
out of a database while another process is inserting into that table. Postgres
is completely unfazed, while MySQL piles up connections until it falls apart
like a house of cards.
For those of you wondering about persistent connections in PHP, they don't
appear to benefit MySQL that much, whereas they are a clear boon for Postgres.
In fact, Postgres benchmarked as much as 30% faster just by using persistent
connections. That tells me that Postgres has a tremendous amount of overhead in
its connection-opening and authentication process. Some of this may be the
fault of Linux and its relatively lame process scheduler. Still, MySQL on the
same box beat it handily no matter how you look at it.
| Comments: |
| RE: arabic text from sql database | abdouz | 09/14/05 07:02 |
| MySQL vs MaxDB- Is this 2 differ? | Gus Doh | 08/05/05 05:10 |
| user and group | adnan | 06/08/05 01:55 |
| arabic text from sql database | Rehab | 04/18/05 06:04 |
| RE: MySQL to PostgreSQL | pniker | 04/01/05 05:09 |
| MySQL is FREE | Bastian Pope | 02/01/05 15:15 |
| Date stamp on article | David Soussan | 01/27/05 03:34 |
| MySQL to PostgreSQL | jon | 01/14/05 00:44 |
| MySQL to PostgreSQL | jon | 01/14/05 00:26 |
| RE: Stored Procedures | kris | 01/10/05 08:17 |
| freaking BS, I enjoyed the IP | Sex | 12/04/04 17:37 |
| RE: MySQL is NOT free | Tim Wasson | 04/06/04 16:48 |
| No transactions in MySQL? | Patrick | 03/29/04 16:27 |
| RE: Let us compare apples with apples | Chris | 03/21/04 05:36 |
| MySQL IS FREE | YOZZY | 01/13/04 22:03 |
| Re: postgres serial type - not now a problem | Andrew | 09/10/03 16:06 |
| Firebirdsql is free and realy stable | HQ+ | 09/05/03 06:47 |
| RE: MySQL is NOT free | Scott Marlowe | 07/25/03 15:34 |
| Progress - being spatial | Robert Churchill | 06/03/03 16:56 |
| RE: MySQL is NOT free | Armond Carroll | 05/11/03 08:18 |
| RE: MySQL is NOT free (FALSE!) | Cybertinus | 04/26/03 08:23 |
| Let us compare apples with apples | Rene | 04/24/03 13:21 |
| RE: MySQL is NOT free (FALSE!) | Mathieu B. | 04/11/03 12:24 |
| MySQL is NOT free | Pierre Couderc | 03/07/03 14:56 |
| RE: RE: inexperience. | greg | 02/20/03 05:03 |
| RE: inexperience. | mike | 12/18/02 21:59 |
| MySQL is technically free* | Jordan | 11/12/02 12:58 |
| MySQL free? | Pierre Couderc | 10/30/02 05:12 |
| Nada Mejor que MySql | Samuel Guzmán | 09/20/02 10:13 |
| say, greater than 500,000 pages | $Sp0T | 09/16/02 13:59 |
| RE: PostgreSQL and PHP | nitha | 09/12/02 02:36 |
| RE: postgresql vs MySQL | Seymour Blackman | 08/24/02 08:39 |
| Converting a postgresql php script to mysql?? | Steve Kemp | 07/18/02 23:38 |
| a lion or a shark? | John Ravich | 07/14/02 03:00 |
| RE: postgresql and mysql | Steve Eley | 07/09/02 14:40 |
| Print this article | David M. Parson | 07/09/02 14:25 |
| postgresql and mysql | srinivas | 07/03/02 15:26 |
| postgres front end tool similar like Erwin. | sekhar | 06/28/02 02:12 |
| transcationnal and relationnal for MySQL | Thom | 06/17/02 10:57 |
| recovery utility after postgresql crash | Prime Ho | 06/13/02 11:24 |
| VB6,Entr et PostGres | Guizani Abderrazek | 06/12/02 04:24 |
| Direction of MySQL vs. PostgreSQL development | Anders Nielsen | 05/30/02 07:24 |
| RE: Transacciones, Trigger y Store Procedure | thierry | 05/29/02 18:06 |
| Transacciones, Trigger y Store Procedure | Jose Cota | 05/27/02 13:38 |
| Thanks for the article. | Bob Hustead | 05/21/02 13:28 |
| MySQL vs PgSQL | Ray | 05/19/02 18:58 |
| RE: HELP!! | ALEX | 05/18/02 08:16 |
| RE: MySQL book? | JEMIMA | 05/15/02 17:33 |
| HELP!!! | Jade | 05/01/02 22:23 |
| MySql problem? | Daniel | 04/30/02 11:10 |
| What about the other options? | mitch | 04/25/02 14:57 |
| Postgres for Windows (CygWin) | Marcel Wojciechowski | 04/24/02 20:21 |
| currval(), last_insert_id(), @@IDENTITY ?? | Jeff Ward | 04/24/02 16:54 |
| RE: ASP | bryan | 04/22/02 20:39 |
| RE: Can VB Connected with My Sql ? | Durai Murugan.D | 04/19/02 02:32 |
| RE: Need update -MySQL 3.23.49 vs PostgreSQL | Matthew Hawkins | 04/04/02 02:37 |
| RE: apples & pears? | Rick Ellis | 04/02/02 12:28 |
| RE: postgressql v mysql | Rick Ellis | 04/02/02 12:25 |
| RE: Need update -MySQL 3.23.49 vs PostgreSQL 7.2 | Hano de la Rouviere | 03/19/02 16:25 |
| RE: What happened with www.postgreslq.org?? | Adam | 03/08/02 16:37 |
| RE: apples & pears? | LUIS | 03/06/02 14:47 |
| postgressql v mysql | A.SMITH | 03/04/02 07:46 |
| RE: What is a connection... | Peter Hsiao | 02/26/02 11:23 |
| Need update -MySQL 3.23.49 vs PostgreSQL 7.2 | Larry Alan Smith | 02/18/02 06:17 |
| Need your feedback. | An Honest Man | 02/14/02 02:07 |
| RE: export ms sql to postgres!!! | gLn23 | 02/04/02 03:17 |
| RE: PostgreSQL and PHP | gLn23 | 02/04/02 03:12 |
| apples & pears? | Holger | 02/02/02 05:46 |
| ORACLE 9I | ROSSELLA | 01/31/02 16:18 |
| how about an update | Visitor | 01/29/02 01:03 |
| PostgreSQL and PHP | rakesh | 01/28/02 02:29 |
| postgresql and mysql | Mathe Imre | 01/22/02 05:52 |
| RE: Comparision among DB Managers | Jaime | 01/21/02 12:21 |
| RE: Can VB Connected with My Sql ? | iqof188 | 01/21/02 04:00 |
| RE: Any comparison chart ? MySQL + others SQL | PaulH | 01/18/02 11:58 |
| Stored Procedures | Michael Fisher | 01/17/02 12:43 |
| Comparision among DB Managers | Juan | 01/03/02 17:10 |
| manejadores de bases de datos | oscar | 01/02/02 11:34 |
| VB6.0 + ODBC + PostgreSQL | Dean | 01/02/02 04:13 |
| RE: Problem with MySQL ??? | kendrick_wilson | 12/31/01 12:04 |
| Problem with MySQL ??? | Khalid | 12/24/01 02:40 |
| MySQL and DB corruption | Odd-Arne Johansen | 12/18/01 19:39 |
| RE: Image files in postgresql | Merlin | 12/17/01 11:36 |
| Fully qualified table names in Postgres | Ben Nicolas | 12/13/01 16:01 |
| RE: Can VB Connected with My Sql ? | Sommai Fongnamthip | 12/13/01 02:59 |
| RE: inexperience. | Hobbit | 12/09/01 14:04 |
| postgre | n.c.nagarjuna reddy | 12/07/01 01:25 |
| RE: MS Sql - is it really the only solution? | He is talking about MySQL.. not MSSQL | 12/05/01 12:16 |
| RE: Can I use MySQL in a large network | Roland | 12/05/01 01:05 |
| MS Sql - is it really the only solution? | Jerome Schellie | 11/24/01 14:36 |
| Mysql/PostgeSQL/ODBC/MacOSX/4D | Abra | 11/24/01 11:41 |
| Can VB Connected with My Sql ? | Prasad | 11/24/01 08:41 |
| Any comparison chart ? MySQL + others SQL | Nelson | 11/23/01 05:26 |
| Tim, you may be a redneck... :B | Peter G | 11/21/01 11:05 |
| Convert Postgresql to Mysql | Peter | 11/19/01 11:58 |
| RE: MySQL being phased out? | Grant Table | 11/19/01 11:19 |
| RE: Image files in postgresql | Michael | 11/14/01 12:58 |
| MySQL being phased out? | emte | 10/29/01 16:47 |
| Postgres | Luc Gevaert | 10/23/01 07:40 |
| MySQL 4.0 launched! | Bjorn | 10/22/01 11:11 |
| Mysql in CD | Meenakshi Sundarem | 10/19/01 02:50 |
| dynamic sql | Peter | 10/19/01 01:11 |
| How can I make a my SQL database ? | Ali Hassan Al Fardan | 10/16/01 15:51 |
| Can I use MySQL in a large network | Felix M. Peria | 10/16/01 02:21 |
| informacion urgente | JAVIER | 09/28/01 12:48 |
| Image files in postgresql | GLR | 09/27/01 15:09 |
| export ms sql to postgres!!! | oswaldo | 09/24/01 09:43 |
| MySQL vs. PostgreSQL | dynamix | 09/21/01 03:51 |
| RE: PostgreSQL for Windows | Sergei Nossov | 09/12/01 03:17 |
| sapdb source | Juan Fernando | 09/06/01 08:22 |
| RE: PostgreSQL for Windows | Will Green | 09/05/01 07:03 |
| mysql | djin | 09/04/01 12:49 |
| mysql | djin | 09/04/01 00:10 |
| RE: MySQL is realy unstable | Michael B | 08/26/01 13:47 |
| PostgreSQL for Windows | Yogesh Shahir | 08/23/01 22:05 |
| PostgreSQL for Windows | Yogesh Shahir | 08/23/01 21:51 |
| RE: MySQL book? | Kasper Schoonman | 08/17/01 12:01 |
| RE: MySQL book? | Kasper Schoonman | 08/17/01 11:58 |
| RE: MySQL weak points !!!!!!!!!!!!!!!!!!!!!!! | morpheus | 08/16/01 09:43 |
| RE: MySQL is realy unstable | Iavor | 08/11/01 18:37 |
| 2-way Replication | Roel | 08/06/01 04:14 |
| RE: Mysql is more easy to use | spikeymikey | 07/22/01 21:16 |
| MySQL daemon crashing | James | 07/14/01 13:58 |
| RE: MySQL book? | James | 07/14/01 13:53 |
| Is there an alternative to M$ SQL ? | furby | 07/12/01 10:33 |
| problem connecting to mysql? | Piotr Klaban | 07/10/01 01:47 |
| GUI interface for postgres on Xwindows | Douglas Sykes | 07/06/01 03:00 |
| I Have Problem | piyapong | 07/01/01 16:05 |
| RE: MySQL is realy unstable | Alexandre Santos | 06/30/01 07:42 |
| RE: commercial RDBMS and Postgresql | stef | 06/28/01 22:11 |
| Back end for win-doze DB apps | Michael Boyle | 06/24/01 15:05 |
| RE: commercial RDBMS and Postgresql | Alexandre Santso | 06/24/01 10:06 |
| MySQL is realy unstable | DuNSuN | 06/21/01 11:23 |
| It is the reason for Microsoft SQl | DuNSuN | 06/21/01 11:22 |
| RE: Inexperience | sgelinas | 06/20/01 09:55 |
| commercial RDBMS and Postgresql | Lisa | 06/18/01 07:55 |
| RE: PGSQL corrupted tables - RECOVERY is CRITICAL | Bruce Irvine | 06/05/01 15:28 |
| Inexperience | Gresh | 05/31/01 09:57 |
| RE: PHP Triad-mysql V postgresql | Carlos | 05/29/01 23:34 |
| suitable databases for scientific application | amaury deldicque | 05/23/01 02:14 |
| RE: BIFF: "irregardless" IS a word | Jeff | 05/22/01 12:32 |
| MySQL book? | Katie | 05/18/01 21:03 |
| RE: DataBase for Arabic Data | Ammar Ibrahim | 05/17/01 09:35 |
| You can check this Database comparison | Suggestion | 05/13/01 03:48 |
| inheritance in postgresql | rishabh gupta | 05/05/01 14:24 |
| Please Help Me | Christian Sueiras Figueroa | 05/04/01 15:12 |
| Mysql is more easy to use | Antonio | 05/04/01 10:16 |
| Postgress/MySQL: Memory Footprints? | Iris | 05/02/01 17:43 |
| Postgresql or MySQL | Antonio | 04/25/01 13:28 |
| i still don't know which to use? | Bill Moss | 04/24/01 12:23 |
| PHP Triad-mysql V postgresql | Steve Patton | 04/20/01 16:50 |
| Postgress & password | tomek zielinski | 04/17/01 07:57 |
| MySQL vs. Postgresql | Netguru | 04/17/01 02:10 |
| RE: No subselects hurts MySQL | Bryan Hunt | 04/09/01 12:53 |
| Backup | Alexandre | 03/29/01 09:50 |
| RE: MySQL/PostGres | Carlos Alejandro PEREZ | 03/25/01 23:31 |
| RE: Is Postgres available for Windows NT? | Erick Papadakis | 03/25/01 03:59 |
| RE: Is Postgres available for Windows NT? | Francis Purcell | 03/23/01 19:07 |
| Sol 8 Intel + Multibyte-Char Supp | Zelda | 03/20/01 23:44 |
| RE: Request | Mallissin | 03/16/01 14:10 |
| RE: php problem | Kristoff | 03/08/01 18:00 |
| Is Postgres available for Windows NT? | Gusti | 03/07/01 10:19 |
| Easy to migrate to other database | Simon | 03/03/01 05:20 |
| i would merge both | Luis Julian | 02/28/01 18:04 |
| RE: Irregardless | spikeymikey | 02/15/01 19:10 |
| mysql/php comparison | robert Mummendey | 02/07/01 09:58 |
| DataBase for Arabic Data | Mounir Eddabbabi | 02/04/01 02:45 |
| Request | kapil tilwani | 02/04/01 00:18 |
| RE: Thoughts on Interbase? | Anduin Withers | 01/28/01 18:19 |
| What happened with www.postgreslq.org?? | Marta Tabares | 01/26/01 09:49 |
| Postgres Pro | Beorn Harris | 01/25/01 10:43 |
| RE: last_insert_id() == currval(sequence) | Marco Antonio | 01/23/01 18:20 |
| MySQL/PostGres | Nate Lee | 01/23/01 14:26 |
| Postgres source for 7.1 | Jeremy Young | 01/22/01 11:20 |
| RE: Literature on PostgreSQL | Robert Hurst | 01/21/01 16:05 |
| RE: Literature on PostgreSQL | Steve | 01/20/01 08:08 |
| RE: MySQL control tools | Brent Matzelle | 01/17/01 15:23 |
| RE: MySQL control tools | Michael Mok | 01/12/01 01:06 |
| MySQL control tools | Daniel Mercury | 01/07/01 07:24 |
| Postgresql 7.1 beta RPMs? | Jean-Michel POURE | 12/17/00 09:06 |
| RE: Did you all really choose? | Carl Schmidt | 12/14/00 00:51 |
| utf-8 | Dennis | 12/11/00 22:03 |
| RE: Postgres and graphics database | Neil Davis | 12/08/00 15:46 |
| RE: MySQL weak points !!!!!!!!!!!!!!!!!!!!!!!!!!! | Neil Davis | 12/08/00 15:39 |
| Postgres and graphics database | eugénie | 12/08/00 09:44 |
| MySQL weak points !!!!!!!!!!!!!!!!!!!!!!!!!!! | Rony Saliba | 12/08/00 05:46 |
| RE: Did you all really choose? | SteveH | 11/28/00 01:43 |
| Pg-ist option found! | Errno | 11/16/00 04:19 |
| Did you all really choose? | Errno | 11/15/00 17:13 |
| Literature on PostgreSQL | Holger Jakobs | 11/13/00 02:41 |
| RE: No subselects hurts MySQL | Patrick Chase | 11/12/00 01:15 |
| RE: MySQL caveats | David Phillips | 11/09/00 22:52 |
| RE: How to use transaction in php&mysql? | Michael McGinley | 10/27/00 09:44 |
| Return a recordset using pg stored procedure | Neil p Davis | 10/23/00 11:38 |
| RE: No subselects hurts MySQL | Anonymous | 10/21/00 19:32 |
| RE: How to use transaction in php&mysql? | Eduardo Perez | 10/21/00 10:39 |
| Your story has an "oopsy" :-) | Terence | 10/12/00 08:50 |
| How to Hobble Your DBMS App | Martin C | 10/11/00 03:27 |
| MySQL caveats | Grzegorz Mucha | 10/05/00 10:28 |
| missing mysql functions hacks / info | philip olson | 10/03/00 23:14 |
| RE: Linux? | Kuba Ober | 08/27/00 11:06 |
| RE: MySQL is not so bad! | Rick Ellis | 08/17/00 18:19 |
| RE: MySQL is for READS | Rick Ellis | 08/17/00 18:18 |
| RE: Linux? | Hunter M | 08/02/00 16:44 |
| RE: Linux? | Hunter M | 08/02/00 16:37 |
| RE: Linux? | Juvenal A. Silva Jr. | 07/30/00 18:33 |
| Linux? | pete | 07/21/00 06:40 |
| RE: REFERENCES tbl.field is not implemented | George Herson | 07/20/00 21:13 |
| RE: REFERENCES tbl.field is not implemented | Martin Goodson | 07/19/00 19:18 |
| RE: REFERENCES tbl.field is not implemented | Martin Goodson | 07/19/00 19:17 |
| RE: REFERENCES tbl.field is not implemented | Martin Goodson | 07/19/00 19:13 |
| RE: REFERENCES tbl.field is not implemented | Martin Goodson | 07/19/00 19:11 |
| RE: REFERENCES tbl.field is not implemented | Martin Goodson | 07/19/00 19:10 |
| RE: Message Board Workaround | Kelly L. Fulks | 07/18/00 13:06 |
| RE: How to use transaction in php&mysql? | Thomas Carrie | 07/17/00 13:07 |
| Java JDBC better for MySQL | Don Corley | 07/17/00 05:15 |
| How to use transaction in php&mysql? | Cui Rong | 07/15/00 10:40 |
| MySQL is not so bad! | Leos Literak | 07/14/00 15:39 |
| Choise by context | Fredrik | 07/14/00 05:08 |
| MySQL is for READS | Doug Collinge | 07/12/00 19:22 |
| Message Board Workaround | R. Moose | 07/11/00 12:58 |
| RE: REFERENCES tbl.field is not implemented | Matt | 07/11/00 12:55 |
| RE: have to kill MySQL 30 days? cold backups? | Matt | 07/11/00 12:45 |
| RE: have to kill MySQL 30 days? cold backups? | Matt | 07/11/00 12:38 |
| RE: Irregardless | Benjamin Keil | 07/10/00 22:56 |
| last_insert_id() == currval(sequence) | Adrian Filipi-Martin | 07/10/00 19:15 |
| RE: have to kill MySQL 30 days? cold backups? | Adam Morris | 07/10/00 12:39 |
| Irregardless | David Costakos | 07/10/00 10:17 |
| Irregardless is not a 'real' word | Adam Ruth | 07/10/00 09:48 |
| RE: BIFF: "irregardless" IS a word | Ion Chalmers Freeman | 07/10/00 08:43 |
| REFERENCES tbl.field is not implemented | Jason hihn | 07/10/00 08:20 |
| Interbase is a good alternative | Ladislav Janiga | 07/10/00 07:07 |
| Increasing blocksize raises 8192 byte bar | Daniel Lundin | 07/10/00 05:25 |
| Its a cheap aol-newsgroup word though. | L Workman | 07/10/00 05:02 |
| BIFF: "irregardless" IS a word | Jesus M. Castagnetto | 07/10/00 02:09 |
| RE: cold backups? | David Moffett | 07/09/00 20:21 |
| RE: cold backups? | Leon Brooks | 07/09/00 19:33 |
| RE: equivalent of mysql_insertid | Rolf-Ørjan Høgset | 07/09/00 19:24 |
| If you need them? | Leon Brooks | 07/09/00 19:21 |
| RE: Thoughts on Interbase? | Roelof Osinga | 07/09/00 19:16 |
| MYSQL is ROCK SOLID STABLE | Wayne | 07/09/00 17:15 |
| PGSQL corrupted tables - RECOVERY is CRITICAL | Øystein Homelien | 07/09/00 16:53 |
| RE: Thoughts on Interbase? | Sourav Laskar | 07/09/00 16:15 |
| equivalent of mysql_insertid | Kirk Parker | 07/09/00 15:48 |
| RE: "irregardless"... Biff is not a name | Paul | 07/09/00 15:21 |
| 8k rows vs. Large Objects | chris vale | 07/09/00 14:38 |
| Re: No subselects hurts MySQL | Tom Haapanen | 07/09/00 13:46 |
| RE: You cannot beat Postgres for stability | Andy Armstrong | 07/09/00 13:37 |
| RE: No subselects hurts MySQL | Andy Armstrong | 07/09/00 13:35 |
| Thoughts on Interbase? | Dallas Hockley | 07/09/00 13:25 |
| Postgres equivalent of mysql_insertid() | Fluffy | 07/09/00 13:24 |
| "irregardless" is not a word | Biff Demchek | 07/09/00 13:11 |
| Consistent Views and Deadlocks | Paul C. Bryan | 07/09/00 13:04 |
| No subselects hurts MySQL | Troy Engel | 07/09/00 12:41 |
| You cannot beat Postgres for stability | Simon Brooke | 07/09/00 12:35 |
| MySQL long-term stability NOT a problem | David E. Storey | 07/09/00 12:27 |
| DB Connections | Dave Bauer | 07/09/00 12:21 |
| have to kill MySQL 30 days? cold backups? | Paul Drake | 07/09/00 12:17 |
| RE: Sub-Selects ? | Miklos Niedermayer | 07/09/00 08:22 |
| What is a connection... | Joseph Lyons | 07/08/00 16:08 |
| RE: Sub-Selects ? | Sourav Laskar | 07/08/00 14:25 |
| Cron-job kill and restart, performance-tuning | Sebastian Benner | 07/08/00 04:12 |
| RE: Sub-Selects ? | Mukul Sabharwal | 07/08/00 03:29 |
| did you tune? | Paul Houle | 07/07/00 18:41 |
| RE: Sub-Selects ? | Alex V | 07/07/00 12:21 |
| Sub-Selects ? | Mukul Sabharwal | 07/07/00 10:44 |
| RE: php problem | Joe Reid | 07/07/00 08:55 |
| php problem | majidah | 07/07/00 04:15 |
|
If you are looking for help, please post on the appropriate forum here. Your questions will be answered much more quickly.
|