{"id":1496,"date":"2018-01-19T19:22:54","date_gmt":"2018-01-19T19:22:54","guid":{"rendered":"http:\/\/goofy-trucks.flywheelsites.com\/mysql-and-postgresql-compared\/"},"modified":"2018-01-19T19:24:50","modified_gmt":"2018-01-19T19:24:50","slug":"mysql-and-postgresql-compared","status":"publish","type":"post","link":"https:\/\/phpbuilder.com\/mysql-and-postgresql-compared\/","title":{"rendered":"MySQL and PostgreSQL Compared"},"content":{"rendered":"<div class=\"phpbuilder-content\">\n<div class=\"phpbuilder-meta\">\n<div class=\"\">By Tim Perdue<\/div>\n<div class=\"\">on July 30, 2000<\/div>\n<\/p><\/div>\n<div id=\"overflow-content\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/phpbuilder.com\/wp-content\/uploads\/2018\/01\/tim2.jpg\" class=\"articleAuthorImg\" alt=\"picture of Tim Perdue\" height=\"90\" width=\"100\" align=\"left\"\/><\/p>\n<div class=\"articlePara\">\nWhich database do I use: Postgres or MySQL? This age-old question has plagued<br \/>\ndevelopers for, what, at least a couple years now. I&#8217;ve used both databases<br \/>\nextensively (MySQL for about one year and Postgres for about 2 years) and was<br \/>\ncurious if the performance differences between the two were as stark as the<br \/>\nMySQL website suggests.<\/div>\n<div class=\"articlePara\">\nI had actually benchmarked the two databases back in September 1999 when we<br \/>\nwere starting to lay the groundwork for SourceForge. At the time, the<br \/>\nperformance difference was so stark that we had to go with MySQL even though I<br \/>\nhad always used Postgres for all my work. The rest of the developers were used<br \/>\nto MySQL and that pretty much cinched the decision.<\/div>\n<div class=\"articlePara\">\nThis time around, rather than using some contrived benchmarking scheme, I<br \/>\nwanted to grab a &#8220;real life&#8221; web page from a &#8220;real&#8221; web site and see how it<br \/>\nperformed on the two databases. The page in question was the discussion forum<br \/>\non SourceForge. It involves some relatively straightforward joins of three<br \/>\ntables, each with 20-30,000 rows of data. It also involves some recursive<br \/>\nqueries to show nested messages, so the database is the true bottleneck on this<br \/>\npage, not PHP.<\/div>\n<div class=\"articlePara\">\nTo get started, I dumped real data out of the production database, modified the<br \/>\ntable SQL and imported it all into MySQL 3.22.30 and PostgreSQL 7.0.2 on Red<br \/>\nHat Linux 6.2 and a VA Linux quad-xeon 4100 server with 1GB RAM.<\/div>\n<div class=\"articlePara\">\nThe first problem I ran into was that Postgres has an arcane limit of 8k of data<br \/>\nper row. In a message board, you&#8217;re going to occasionally surpass 8k of data<br \/>\nin a row, and so postgres choked on the import. To get around this, I just<br \/>\ndropped out the &#8220;body&#8221; of the message and re-imported the data. The Postgres<br \/>\ndevelopment team is aware of this limitation and are fixing it in v7.1, and<br \/>\nthey also noted that you can recompile Postgres to support up to 32k,<br \/>\nalthough at a possible detriment to overall performance.<\/div>\n<div class=\"articlePara\">\nAt this point, I ran into another small issue with Postgres &#8211; its &#8220;serial&#8221; data type (the<br \/>\nequivalent of MySQL&#8217;s auto_increment) creates a &#8220;sequence&#8221; which does not get<br \/>\ndropped when its parent table is dropped. So if you try to re-create the table,<br \/>\nyou&#8217;ll get a name conflict for this sequence. A lot of new users would be<br \/>\nconfused by this, so Postgres loses a couple points for that. Also, MySQL is<br \/>\n&#8220;smart&#8221; enough to increment its auto_increment value when you import data,<br \/>\nwhereas Postgres&#8217; sequence does not get reset when you import data, causing all<br \/>\nnew inserts to fail.<\/div>\n<\/div>\n<p><\/p>\n<div style=\"float: left; padding:15px; color:#17AAF3\">\n<div style=\"background-color:#B6E5FC; font-size:16px; margin-top:1px; padding:1px 4px 1px 4px; color:#000; font-style:bold; float:left;\">1<\/div>\n<div style=\"float:left; font-size:16px; color:#FF7A22; padding:2px 2px 2px 2px; \">| <\/div>\n<div style=\"float:left; padding:2px 4px 2px 4px;\"><a class=\"pageNumber\" href=\"tim200007054658.html?page=2\">2<\/a> <\/div>\n<div style=\"float:left; font-size:16px; color:#FF7A22; padding:2px 2px 2px 2px; \">| <\/div>\n<div style=\"float:left; padding:2px 4px 2px 4px;\"><a class=\"pageNumber\" href=\"tim200007059ba9.html?page=3\">3<\/a> <\/div>\n<div style=\"float:left; font-size:16px; color:#FF7A22; padding:2px 2px 2px 2px; \">| <\/div>\n<div style=\"float:left; padding:2px 4px 2px 4px;\"><a class=\"pageNumber\" href=\"tim20000705fdb0.html?page=4\">4<\/a> <\/div>\n<div style=\"float:left; font-size:16px; color:#FF7A22; padding:2px 2px 2px 2px; \">| <\/div>\n<div style=\"float:left; padding:2px 4px 2px 4px;\"><a class=\"pageNumber\" href=\"tim20000705af4d.html?page=5\">5<\/a> <\/div>\n<div style=\"float:left; padding:2px;\"><a class=\"paginationPageLink\" href=\"tim200007054658.html?page=2\">Next Page \u00bb<\/a><\/div>\n<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>By Tim Perdue on July 30, 2000 Which database do I use: Postgres or MySQL? This age-old question has plagued developers for, what, at least a couple years now. I&#8217;ve used both databases extensively (MySQL for about one year and Postgres for about 2 years) and was curious if the&#8230; <a href=\"https:\/\/phpbuilder.com\/mysql-and-postgresql-compared\/\" class=\"readmore\"><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-1496","post","type-post","status-publish","format-standard","hentry","category-tutorials"],"_links":{"self":[{"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/posts\/1496","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/comments?post=1496"}],"version-history":[{"count":1,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/posts\/1496\/revisions"}],"predecessor-version":[{"id":2254,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/posts\/1496\/revisions\/2254"}],"wp:attachment":[{"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/media?parent=1496"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/categories?post=1496"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/tags?post=1496"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}