Differences between current version and revision by previous author of PostgresVsMysql.
Other diffs: Previous Major Revision, Previous Revision, or view the Annotated Edit History
Newer page: | version 38 | Last edited on Tuesday, January 25, 2011 5:54:28 pm | by AristotlePagaltzis | |
Older page: | version 36 | Last edited on Tuesday, March 31, 2009 4:20:21 pm | by LawrenceDoliveiro | Revert |
@@ -1,75 +1,73 @@
<?plugin OldStyleTable
-|^ __Feature__ | __[MySQL] 3.x__ | __[MySQL] 4..x__ | __[MySQL] 4.1.x__ | __[MySQL] 5.x]
__ | __[PostgreSQL]__
-| SubSelect~s | No | Some | Yes |Yes | Yes
-| Views | No | No | No |Yes | Yes
-| Foreign Key relationships | No | Yes | Yes |Yes | Yes
-| Foreign Key constraints | No | No | No |Yes | Yes
-| Triggers | No | No | No |Yes | Yes
-| Indexing on non trivial types | No | No | No |Yes | Yes
+|^ __Feature__ | __[MySQL] 3.x__ | __[MySQL] 4..x__ | __[MySQL] 4.1.x__ | __[MySQL] 5.x__ | __[PostgreSQL]__
+| SubSelect~s | No | Some | Yes | Yes | Yes
+| Views | No | No | No | Yes | Yes
+| Foreign Key relationships | No | Yes | Yes | Yes | Yes
+| Foreign Key constraints | No | No | No | Yes | Yes
+| Triggers | No | No | No | Yes | Yes
+| Indexing on non trivial types | No | No | No | Yes | Yes
| Sequences | Some<sup>1</sup> | Some<sup>1</sup> | Some<sup>1</sup> | Some<sup>1</sup> | Yes
| Transactions | No | Yes | Yes | Yes | Yes
-| OO (Inheritance of tables) | No | No | No
| No | Yes
-| Async Notifications | No | No | No
| No | Yes
+| Transactional DDL statements | No | No | No | No | Yes
+
| OO (Inheritance of tables) | No | No | No
| No | Yes
+| Async Notifications | No | No | No
| No | Yes
| Constraints | No | No | No | Yes | Yes
-| SELECT INTO
| No | Yes<sup>2</sup>
| Yes<sup>2</sup>
| Yes<sup>2</sup>
| Yes
-| Stored Procedures | No | No | No | Yes
| Yes
-| Row level locking | Yes<sup>3
</sup> | Yes<sup>3
</sup> | Yes<sup>3
</sup> | Yes<sup>3
</sup> | Yes
+| INSERT ...
SELECT
| No | Yes
| Yes
| Yes
| Yes
+| Stored Procedures | No | No | No | Yes
| Yes
+| Row level locking | Yes<sup>2
</sup> | Yes<sup>2
</sup> | Yes<sup>2
</sup> | Yes<sup>2
</sup> | Yes
| Table level locking | Yes | Yes | Yes | Yes | Yes
-| Geospatial Datatypes (ie WKT)
| No
| Yes | Yes | Yes | No<sup>4
</sup>
-| [Multiversion Concurrency Control | http://www.postgresql.org/docs/7.4/interactive/mvcc.html] | No | No | No | No | Yes<sup>5
</sup>
-| Native replication (M/M, M/S, Ring) | Yes | Yes | Yes | Yes | No<sup>6
</sup>
+| Geospatial Datatypes (ie WKT) | No
| Yes | Yes | Yes | No<sup>3
</sup>
+| [Multiversion Concurrency Control | http://www.postgresql.org/docs/7.4/interactive/mvcc.html] | No | No | No | No | Yes<sup>4
</sup>
+| Native replication (M/M, M/S, Ring) | Yes | Yes | Yes | Yes | No<sup>5
</sup>
?>
# Only __auto_increment__ is supported
-# But it's spelled __INSERT INTO ... SELECT__ ("SELECT INTO" is actually a Sybase SQL extension, "INSERT INTO ... SELECT" is actually the SQL standard)
# Only with InnoDB tables
# Unless you use PostGIS which is a patch against PostgreSQL, but often lags behind the latest version
-# __Beware!__ As a result of MVCC, PostgreSQL cannot optimize a simple SELECT count
(*) FROM table query. It will always use a sequential scan, this becomes very slow even on a table with only a few hundred thousand rows. This type of query is somewhat common in webapps (though rarely necessary), as a result you have to design your database and app around it. Alternately, this can be emulated fairly trivially with a trigger that updates a counter on create/deletion of a new row. People often assume this type of query is free in terms of processing. In MySQL it is optimised away.
+# __Beware!__ As a result of MVCC, PostgreSQL cannot optimize a simple <tt>
SELECT COUNT
(*) FROM table</tt>
query. It will always use a sequential scan, this becomes very slow even on a table with only a few hundred thousand rows. This type of query is somewhat common in webapps (though rarely necessary), as a result you have to design your database and app around it. Alternately, this can be emulated fairly trivially with a trigger that updates a counter on create/deletion of a new row. People often assume this type of query is free in terms of processing. In MySQL it is optimised away.
# There are several projects out there with implement heavy modifications to PostgreSQL to implement replication, some rely on adding triggers to your database
-
-
~UniForum posted studies that concluded that [MySQL] is slightly faster per query, but [PostgreSQL] can handle more concurrent connections. If you have that kind of load you really want to be looking at having redundancy and/or a bigger/better DataBase ([Oracle]?), though (Although, PostgreSQL is robust enough to handle the .info and .org domain registry databases).
-
+~UniForum posted studies that concluded that [MySQL] is slightly faster per query, but [PostgreSQL] can handle more concurrent connections.
----
!! Some comments on [a comparison of exporting data to MySQL and PostgreSQL | http://www-css.fnal.gov/dsg/external/freeware/Repl_mysql_vs_psql.html]:
-__SPEED
__:
+__Speed
__:
[PostgreSQL] in most instances is nearly the same speed as [MySQL].
In many more complicated instances [MySQL] cannot index on fields where [PostgreSQL] can,
leading to order of magnitude speedups for postgres.
-__STABILITY
__:
+__Stability
__:
I can't say I know anything about [Java]'s [JDBC] interface, so I won't comment here.
-__DATA INTEGRITY
__:
+__Data Integrity
__:
[PostgreSQL] takes a hit because it wants your data to be correct by enforcing constraints.
[MySQL] [has limited referential constraints|http://dev.mysql.com/doc/refman/5.0/en/create-table.html].
-__SPECIAL SERVER SIDE FEATURES
__:
+__Special Server Side Features
__:
Both by default don't listen on the network as a security feature.
[PostgreSQL]'s security is far more advanced than [MySQL]'s
allowing things like IDENT auth etc.
-__LOCKING AND CONCURRENCY SUPPORT
__:
+__Locking and Concurrency Support
__:
[PostgreSQL] has subrow locking of data and
[Multiversion Concurrency Control | http://www.postgresql.org/docs/7.4/interactive/mvcc.html];
[MySQL] still usually (under what conditions, which versions?) locks the entire table.
-__LARGE OBJECTS
__:
+__Large Objects
__:
[PostgreSQL]'s interface for large objects allows for flexible retrieval of data without having
to transmit the entire large object from the DataBase when it is not needed, speeding up many queries.
-__ALTER TABLE
__:
+__Alter Table
__:
[PostgreSQL]'s ALTER TABLE is lacking compared to [MySQL].
In theory, a carefully designed schema should preclude any need for altering
types of columns, but in practice requirements change during the life of a DataBase.
@@ -87,16 +85,13 @@
I stayed with MySQL because I could add free text index to the text fields. When postgres 8.0 came out for windows I thought I would switch back to postgres and try their Tsearch2 index, because I still missed lots of things about Postgres. During the switch I found still postgres familiar and I loved the stored procedures. Sadly however I found postgres incredibly slow and my users refused to accept the postgres text indexing as it way too slow. The interface with proper boolean structures and stemming was much nicer on postgres than mysql. ~PgAdmin is a very nice tool.
With some regret I am going back to MySQL, mainly due to speed. For instance I have a fully index table with about 250,000 rows with full text that I need to create "foreign keys" on another table. Updating the foreign key from another table takes maybe 10 minutes on postgres and less than a minute on mysql. (These are not "real" foreing keys because I think the triggering mechanism would slow updates even more. I tried dropping indexs and it didnt make much diffference. Creating a new table and re-indexing it was faster but this is clumsy. Why not just go back to mysql.
+
+—~StuartGalloway
----
!! See Also
* [PostgreSQL or MySQL?|http://www-css.fnal.gov/dsg/external/freeware/pgsql-vs-mysql.html]
-* Bob Ippolito [hates MySQL |
http://bob.pythonmac.org/archives/2005/08/12/mysql-hate/]
-* [MySQL] has a page where it will unit test the [DBMS]s of your choice and give [a breakdown on whether the feature was available | http://www.mysql
.com/information/features.html].
-* An indepth article on [real world performance testing of MySQL and PostgreSQL | http://www.phpbuilder.com/columns/tim20000705.php3?page=1].
-* [Issues to be aware of when using MySQL | http://sql-info.de/mysql/gotchas.html]
-* [DB comparison against standards|http://troels.arvin.dk/db/rdbms/]
-* Reuven Lerner’s description of [MySQL|http://www.linuxjournal.com/article/9571], [PostgreSQL|http://www.linuxjournal.com/article/9618], and [comparison of the two|http://www.linuxjournal.com/article/9649]
+* http://howfuckedismydatabase
.com/