{"id":1500,"date":"2018-01-19T19:22:54","date_gmt":"2018-01-19T19:22:54","guid":{"rendered":"http:\/\/goofy-trucks.flywheelsites.com\/mysql-and-postgresql-compared-page-4\/"},"modified":"2018-01-19T19:24:50","modified_gmt":"2018-01-19T19:24:50","slug":"mysql-and-postgresql-compared-page-4","status":"publish","type":"post","link":"https:\/\/phpbuilder.com\/mysql-and-postgresql-compared-page-4\/","title":{"rendered":"MySQL and PostgreSQL Compared Page 4"},"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\">\n<h2>PostgreSQL<\/h2>\n<div class=\"articlePara\">\nThe results for Postgres might surprise a few people, as Postgres has somewhat<br \/>\nof a negative reputation among some web developers (initial releases<br \/>\nof Postgres had widely-rumored issues in addition to laggard performance).<br \/>\nAccording to my experience, and these benchmarks, most of that reputation is<br \/>\nunfounded. In fact, it appears that PostgreSQL withstands up to 3 times the<br \/>\nload that MySQL can before throwing any errors &#8212; on the same hardware\/OS<br \/>\ncombination.<\/div>\n<div class=\"articlePara\">\nPostgres happily chugs along at roughly 10 pages\/second, enough to serve about<br \/>\n400,000 pages\/day, assuming a regular traffic curve with the peak at 2x the<br \/>\nbottom. That&#8217;s an awful lot of pages and is far beyond what most people will<br \/>\nsee on their websites. In addition, most of the pages on your site will<br \/>\n<b>not<\/b> be as complex as the one in this test. As with MySQL, you&#8217;ll be happy<br \/>\nto pay for a hardware upgrade if you pass this ceiling. Because of Postgres&#8217;<br \/>\narchitecture, it could probably continue to scale up the more processors and<br \/>\nRAM you give it.<\/div>\n<h2>Wins<\/h2>\n<div class=\"articlePara\">\nWell, postgres has some extremely advances features when shown next to MySQL.<br \/>\nWhile I don&#8217;t use most of the features myself, they are available for the<br \/>\ntruly-hardcore developers out there. Many developers don&#8217;t even realize what<br \/>\nthey&#8217;re missing by not having some of these features available. <\/div>\n<div class=\"articlePara\">\nAn example of where you should be using a transaction is if you are doing<br \/>\nmore than one update\/insert\/delete in a sequence. For instance, your script<br \/>\ninserts a new user into your user table, then also inserts a row in another<br \/>\ntable, and you update a flag somewhere else. In this case, if the first insert<br \/>\nsucceeds, but the second fails, what do you do? With Postgres, you could<br \/>\nRollback the entire operation and show an appropriate error. With MySQL,<br \/>\nyou would wind up in an invalid state, unless you program in a bunch of<br \/>\nlogic to handle the situation. In real-world use, most queries don&#8217;t fail<br \/>\nunless you&#8217;re a lousy programmer, and if the second query did fail, the<br \/>\nresults may not be dire (unless we&#8217;re talking about an accounting\/banking\/critical<br \/>\napplication where there can be no risk of incorrect data).<\/div>\n<div class=\"articlePara\">\nAnyway, foreign-key support is now in Postgres 7.0+, which means that when you insert<br \/>\na row, the database can do some fairly impressive validation checks. Same if<br \/>\nyou delete a row &#8211; it just plain won&#8217;t let you delete a row if another table is<br \/>\ndepending on it. I love this idea and can envision rewriting entire websites<br \/>\njust to take advantage of this feature.<\/div>\n<div class=\"articlePara\">\nTriggers and views are interesting and powerful tools that can be used in<br \/>\nPostgres, but not MySQL. I haven&#8217;t used either one, but I can think of a<br \/>\nhundred uses for Views if I were to redesign SourceForge from the ground up on<br \/>\nPostgres.<\/div>\n<h2>Limitations<\/h2>\n<div class=\"articlePara\">\nThe primary limitation with Postgres is not its performance (as most web sites<br \/>\nwill never run into that barrier), but hard-coded limits like the<br \/>\n8k row size limit (which probably dates back to its earliest days). When I<br \/>\ndesigned Geocrawler.com on Postgres, I had to segment large emails into 8k<br \/>\nchunks to work around this lame limitation. Also, by default, Postgres is<br \/>\ncompiled to only support 32 connections, which is not enough for a high-traffic<br \/>\nweb site, especially when you consider that postgres delivers each page much<br \/>\nmore slowly than MySQL.<\/div>\n<div class=\"articlePara\">\nOne other limitation may bug a lot of PHP users &#8211; Postgres has no equivalent to<br \/>\nMySQL&#8217;s mysql_insertid() function call. That is, if you insert a row into a<br \/>\nMySQL database, MySQL will hand you back the primary key ID for that row. There<br \/>\nis an extremely round-about way of doing this in Postgres, but it&#8217;s a headache<br \/>\nand is probably slow if used a lot.<\/div>\n<h2>Stability<\/h2>\n<div class=\"articlePara\">\nPostgres will run smoothly for extended periods of time without trouble. My<br \/>\nPostgres 6.5.3 install has run for 90 days without blinking on my tired old<br \/>\nPowerMac 8500, while getting about 50-100,000 pages per day. And when postgres<br \/>\ngets loaded, it just bogs down, it doesn&#8217;t quit and give up the ghost under<br \/>\nstress.<\/div>\n<div class=\"articlePara\">\nThe problem with Postgres is that when you <b>do<\/b> have a problem with it,<br \/>\nit&#8217;s usually really bad. Like a fubar database file or, more commonly, a<br \/>\ncorrupted index (which can frequently be dropped\/rebuilt). I have encountered<br \/>\nother serious problems with older versions of postgres (6.4.x) where multiple<br \/>\nsame numbers were inserted into a primary key (something that should be<br \/>\nimpossible under any circumstance).<\/div>\n<div class=\"articlePara\">\nThere have also been problems with Postgres where you can wind up with<br \/>\n&#8220;half-baked&#8221; indexes, tables, etc that you cannot drop or get rid of. I have<br \/>\nnot seen these yet on Postgres 7, but I haven&#8217;t used it enough to know.<\/div>\n<\/div>\n<p><\/p>\n<div style=\"float: left; padding:15px; color:#17AAF3\">\n<div style=\"float:left; padding:2px;\"><a class=\"paginationPageLink\" href=\"tim200007059ba9.html?page=3\">\u00ab Previous Page<\/a><\/div>\n<div style=\"float:left; padding:2px 4px 2px 4px;\"><a class=\"pageNumber\" href=\"tim20000705.html\">1<\/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=\"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=\"background-color:#B6E5FC; font-size:16px; margin-top:1px; padding:1px 4px 1px 4px; color:#000; font-style:bold; float:left;\">4<\/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=\"tim20000705af4d.html?page=5\">Next Page \u00bb<\/a><\/div>\n<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>By Tim Perdue on July 30, 2000 PostgreSQL The results for Postgres might surprise a few people, as Postgres has somewhat of a negative reputation among some web developers (initial releases of Postgres had widely-rumored issues in addition to laggard performance). According to my experience, and these benchmarks, most of&#8230; <a href=\"https:\/\/phpbuilder.com\/mysql-and-postgresql-compared-page-4\/\" 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-1500","post","type-post","status-publish","format-standard","hentry","category-tutorials"],"_links":{"self":[{"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/posts\/1500","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=1500"}],"version-history":[{"count":1,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/posts\/1500\/revisions"}],"predecessor-version":[{"id":3344,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/posts\/1500\/revisions\/3344"}],"wp:attachment":[{"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/media?parent=1500"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/categories?post=1500"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/tags?post=1500"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}