<p>We are currently using MySQL for a product we are building, and are keen to move to PostgreSQL as soon as possible, primarily for licensing reasons.</p>

<p>Has anyone else done such a move? Our database is the lifeblood of the application and will eventually be storing TBs of data, so I'm keen to hear about experiences of performance improvements/losses, major hurdles in converting SQL and stored procedures, etc.</p>

<p>Edit: Just to clarify to those who have asked why we don't like MySQL's licensing. We are developing a commercial product which (currently) depends on MySQL as a database back-end. Their license states we need to pay them a percentage of our list price per installation, and not a flat fee. As a startup, this is less than appealing.</p>

[{'answer_id': 20195, 'author': 'Michał Niedźwiedzki', 'author_id': 2169, 'author_profile': 'https://Stackoverflow.com/users/2169', 'pm_score': 5, 'selected': False, 'text': "<p>Steve, I had to migrate my old application the way around, that is PgSQL->MySQL. I must say, you should consider yourself lucky ;-)\nCommon gotchas are:</p>\n\n<ul>\n<li>SQL is actually pretty close to language standard, so you may suffer from MySQL's dialect you already know</li>\n<li>MySQL quietly truncates varchars that exceed max length, whereas Pg complains - quick workaround is to have these columns as 'text' instead of 'varchar' and use triggers to truncate long lines</li>\n<li>double quotes are used instead of reverse apostrophes</li>\n<li>boolean fields are compared using IS and IS NOT operators, however MySQL-compatible INT(1) with = and &lt;> is still possible</li>\n<li>there is no REPLACE, use DELETE/INSERT combo</li>\n<li>Pg is pretty strict on enforcing foreign keys integrity, so don't forget to use ON DELETE CASCADE on references</li>\n<li>if you use PHP with PDO, remember to pass a parameter to lastInsertId() method - it should be sequence name, which is created usually this way: [tablename]_[primarykeyname]_seq</li>\n</ul>\n\n<p>I hope that helps at least a bit. Have lots of fun playing with Postgres!</p>\n"}, {'answer_id': 74931, 'author': 'Grant Johnson', 'author_id': 12518, 'author_profile': 'https://Stackoverflow.com/users/12518', 'pm_score': 4, 'selected': False, 'text': '<p>I have done a similar conversion, but for different reasons.   It was because we needed better ACID support, and the ability to have web users see the same data they could via other DB tools (one ID for both).</p>\n\n<p>Here are the things that bit us:</p>\n\n<ol>\n<li>MySQL does not enforce constraints\nas strictly as PostgreSQL. </li>\n<li>There are different date handling routines. These will need to be manually converted. </li>\n<li>Any code that does not expect ACID\ncompliance may be an issue.</li>\n</ol>\n\n<p>That said, once it was in place and tested, it was much nicer.  With correct locking for safety reasons and heavy concurrent use, PostgreSQL performed better than MySQL.   On the things where locking was not needed (read only) the performance was not quite as good, but it was still faster than the network card, so it was not an issue.</p>\n\n<p>Tips:</p>\n\n<ul>\n<li>The automated scripts in the contrib\ndirectory are a good starting point\nfor your conversion, but will need\nto be touched a little usually.</li>\n<li>I would highly recommend that you\nuse the serializable isolation\nlevel as a default.</li>\n<li>The pg_autodoc tool is good to\nreally see your data structures and\nhelp find any relationships you\nforgot to define and enforce.</li>\n</ul>\n'}, {'answer_id': 85803, 'author': 'Patrick Desjardins', 'author_id': 13913, 'author_profile': 'https://Stackoverflow.com/users/13913', 'pm_score': 2, 'selected': False, 'text': "<p>We did a move from a MySQL3 to PostgreSQL 8.2 then 8.3. PostgreSQL has the basic of SQL and a lot more so if your MYSQL do not use fancy MySQL stuff you will be OK.</p>\n\n<p>From my experience, our MySQL database (version 3) doesn't have Foreign Key... PostgreSQL lets you have them, so we had to change that... and it was a good thing and we found some mistake.</p>\n\n<p>The other thing that we had to change was the coding (C#) connector that wasn't the same in MySQL. The MySQL one was more stable than the PostgreSQL one. We still have few problems with the PostgreSQL one.</p>\n"}]
['https://Stackoverflow.com/questions/17717', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1693/']