PostgreSQL or MySQL?

PostgreSQL or MySQL?,第1张

概述Don't hope one tool fits all your jobs. To choose between the two databases, you need to understand whether you need the transaction support of Postgres or the large-text-area support in MySQL.

Don't hope one tool fits all your jobs.

To choose between the two databases,you need to understand whether you need the transaction
support of Postgres or the large-text-area support in MysqL.

It's interesting that the two databases appear to be converging to meet in the mIDdle somewhere.
While MysqL is working on adding transaction support and slowly adding features like subselects,
Postgres is making progress in the performance and stability.

Having foreign keys,vIEws,subselects,and transactions can all be very attractive in Postgresql -
if you need them and you will make any use of them. If you don't need them or won't use them,then
you're probably better off with MysqL and its superior performance.




Postgresql versus MysqL: an unbiased comparison
Postgresql MysqL
sql standard COMPliANCE Postgres understands a good subset of sql92/99 plus some object-orIEnted features to these subsets. Postgres is capable of handling complex routines and rules as declarative sql querIEs,subquerIEs,multi-user support,transactions,query optimization,inheritance,and arrays. Does not support selecting data across different databases. MysqL uses sql92 as its foundation. Runs on countless platforms. MysqL can construct querIEs that can join tables from different databases. Supports both left and right outer joins using both ANSI and ODBC Syntax. As of MysqL 4.1 from that release on,MysqL will handle subquerIEs. VIEws supported as of release 5.
PLATFORMS Lacks binary distribution for all the supported plataforms. One of the problems is that Postgresql doesn't run properly on NT as a service by default,you need something like firedaemon to start it. The PgAccess GUI is available on windows as well,but it lacks a few features that psql supports. Non-supported platforms: windows9x/Me,NextStep,ultrix. There are binary distribution for most of the supported plataforms. MysqL works better on windows than Postgresql does. MysqL runs as a native windows application (a service on NT/Win2000/WinXP),while Postgresql is run under the cygwin emulation.
SPEED Postgres slower on low-end but has some options for improving. Postgres forks on every incoming connection - and the forking process and backend setup is a bit slow,but one can speed up Postgresql by Coding things as stored procedures. MysqL is very fast on both simple and complex SELECTs,but might require changing the database type from MyISAM to InnoDB for UPDATE intense applications. MysqL handles connections very fast,thus making it suitable to use MysqL for Web - if you have hundreds of CGIs connecting/disconnecting all the time you'd like to avoID long startup procedures.
STABIliTY Postgresql 6.x serIEs and earlIEr were much worse in this aspect. Random disconnects,core dumps and memory leaks are usual. Postgresql 7.x serIEs was a big improvement. Expect Postgresql 8.x to continue this trend. MysqL does very good job even on the busIEst sites; it certainly has some problems handling hundreds of connections per second,but these problems are resolvable. Random disconnects and core dumps are exceptionally rare.
Myssql has a much larger user base than Postgresql,therefore the code is more tested and has historically been more stable than Postgresql and more used in production environments.
DATA INTEGRITY Postgres does very good job supporting referential integrity,has transactions and rollbacks,foreign keys ON DELETE CASCADE and ON UPDATE CASCADE. MysqL has some basic provisions for referential integrity and transactions/rollbacks. CHECK clause is allowed for compatibility only and has no effect on database operation.
InnoDB tables have FOREIGN KEYs for relational or multi-table delete,and support transaction processing. In MySAM tables FOREIGN KEY is for compatibility only and has no effect on database operation.
SPECIAL server-sIDe FEATURES Postgres has rules,triggers,server-sIDe functions that can be written in C,pgsql,python,perl and tcl languages.
INSTEAD OF rules can be used for updating data through vIEws.
Postgresql has schemas that allow users to create objects in separate namespaces,so two people or applications can have tables with the same name. There is also a public schema for shared tables. table/index creation can be restricted by removing permissions on the public schema.
MysqL has simple (and probably inconvenIEnt) mechanism for server-sIDe shared librarIEs with C functions. Rudimentary support for triggers was included beginning with MysqL 5.0.2. An external development implemented in perl can be used as stored procedures in MysqL.
MysqL has more powerful admin tools included in the distribution (MysqLadmin allows you to watch processes and querIEs in-progress),including hot backup,a file corruption recovery tool and a of couple others. Command-line tools - you can see database and table structures using describe and show commands. Postgres' commands are less obvIoUs ( /d to show a List of tables for instance).
Security Postgres has similar features,but a little less fine-grained. For example,if user can connect to a database,user can CREATE table,thus running Denial-of-Service. On the other hand Postgres can limit logins based on different criteria - network segment,IDent string,etc. MysqL has exceptionally good fine-grained access control. You can GRANT and REVOKE whatever rights you want,based on user name,table name and clIEnt host name.
LOCKING and CONCURRENCY SUPPORT Postgresql has a mechanism called MVCC (MultiVersion Concurrency Control),comparable or superior to best commercial databases. It can do row-level locking,can lock rows for writing in one session but give these rows unaffected in another session. MVCC is consIDered better than row-level locking because a reader is never blocked by writer. Instead,Postgres keeps track of all transactions and is able to manage the records without waiting to become available. MysqL can do table locking for ISAM/MyISAM and HEAP tables,page level locking for BDB tables.
InnoDB has full row level locking support.
LARGE OBJECTS In Postgres,Large Objects are very special beastIEs. You need to create them using lo_create function and store the result of the function - OID - in a regular table. Later you can manipulate the LOB using the OID and other functions - lo_read/lo_write,etc. Large object support is broken in Postgres - pg_dump cannot dump LOBs; you need to develop your own backup mechanism. Tthe team is working on implementing large rows; this will replace current LOB support. In MysqL,text and binary LOBs are just fIElds in the table. nothing special - just INSERT,UPDATE,SELECT and DELETE it the way you like. There are some limitations on indexing and applying functions to these fIElds.
ALTER table Postgres supports ALTER table to some extent. You can ADD ColUMN,REname ColUMN and REname table. MysqL has all options in ALTER table - you can ADD column,DROP it,REname or CHANGE its type on the fly - very good feature for busy servers,when you don't want to lock the entire database to dump it,change deFinition and reload it back.
NATIONAL LANGUAGE SUPPORT Postgres compiled with --enable-locale does some jobs based on its locale settings,and can change locale settings per clIEnt (not per database),which is a bit more flexible. Compiled --with-mb (Multibyte support) Postgres can translate on-the-fly between many predefined character sets. MysqL does some tasks based on its locale settings,but not many.
Date/time formats parsing/generating need more work for both sIDes. Neither system can handle multicharset databases.
总结

以上是内存溢出为你收集整理的PostgreSQL or MySQL?全部内容,希望文章能够帮你解决PostgreSQL or MySQL?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/sjk/1180364.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-02
下一篇 2022-06-02

发表评论

登录后才能评论

评论列表(0条)

保存