设为首页 收藏本站
查看: 932|回复: 0

[经验分享] PostgreSQL 8.4, SQL Server 2008, MySQL 5.1比较

[复制链接]

尚未签到

发表于 2016-5-23 02:03:51 | 显示全部楼层 |阅读模式
  来自:http://www.postgresonline.com/journal/index.php?/archives/130-Cross-Compare-of-PostgreSQL-8.4,-SQL-Server-2008,-MySQL-5.1.html
FeatureMicrosoft SQL Server 2008MySQL 5.1PostgreSQL 8.4OS - Why is this important? Why would you even dream of not running on Windows?  If you decide one day that Microsoft is not your best friend in the whole wide world, you can ditch them or at least on your DB Server (could that ever happen?).  On a side note, Microsoft can't compete with Oracle on Linux/Unix anyway.  If Microsoft has a non-Microsoft DB running on a customer's box, I wonder which database they would prefer  - Oracle, IBM DB2, Sun MySQL or PostgreSQL?Windows Desktop/ServerWindows Desktop/Server , Linux, Unix, MacWindows Desktop/Server, Linux, Unix, MacLicensingCommercial - Closed Source, Various levels of features based on version, Free Crippleware (4 GB limit but free for embedding inclusion)GPL Open Source, Commercial.  Now owned by Oracle, and some of us are still wondering how Oracle will make hay out of its new found treasure. Will they use to upsell. Monty Widenius has an interesting blog entry explaining the MySQL dual licensing and how it has changed.BSD Open Source.  Its the freest of all and many argue about it.  You can fork it all you want without giving back and make your own commercial derivative. Though ironically there are not all that many forks. Netezza forked it initially (though its unclear if any PostgreSQL code lives on in their product), GreenPlum forked it, EnterpriseDb forked to give Oracle features, but to their credit gives back a lot of fixes to the community.Install/Maintenance ProcessMost time-consuming to install and most dependencies, but lots of wizards to help you forget everything and mail you when somethng bad happens (non-free versions)Still Easiest.  There are a lot of prepackaged products with it and its install rarely fails.Medium (I put PostgreSQL at medium because on occasion we have run into issues where we have manually init the db on Windows.  Those are rare though. On Linux its still the deal that MySQL often comes pre-installed for you and for PostgreSQL you have to figure it out yourself or they give you some super antiquated version. With PostgreSQL Yum respository its much easier now if you manage your own box.Drivers already installed on WindowsYes - when you have a windows shop this is huge especially when you are not allowed to install stuff on client desktops and you need to integrate seamlessly with desktop apps.  This is why using SQL Server Linked Server to get at yummy features of PostgreSQL comes in handy.NoNoODBC, JDBC, ADO.NET drivers availableYesYesYesRead-Only ViewsYesYesYesOpen Source products available for itFew except CodePlex/.NETManyFew but ramping up and in PHP more than SQL ServerCommercialModerate -- still a lot of commercial stuff hasn't been certified on 2008 because 2008 is so newModerateModerate -- I think PostgreSQL has improved since last we checked, but probably still lower than MySQL penetration.Updateable ViewsYes - even for 2 table views will automatically make them updateableif they have keys and update does not involve more than one table.  You can write instead of triggers against more complex views to make them updateableYes - Single one table views are automatically updateable, some 2 table views are updateable if they don't have left joins and don't involve update of more than one table.  If you have more complex views you want to make updateable - good riddance - no support for triggers or rules on views.Yes, but not automatic. You have to write rules against views to make them updateable but can make very complicated views updateable as a result.Materialized/Indexable ViewsYes but varies slightly depending on if you are running SQL Express, Workgroup, Standard, Enterprise and numerous restrictions on your views that makes it of limited useNoNo, but there are I think 2 contrib modules e.g. matviews that are simple and basically rebuild the materialized viewCan add columns and change names, data types of views without droppingYesYesYes - sort of - as of 8.4 you can now add columns to the end of view without dropping it.Can drop tables, (drop, change size, data type of columns), and views used in views - this is a arguably a misfeature but sometimes it comes in handy when you are an EXPERT user http://jishudaima.iyunv.com/blog/journal/templates/default/img/emoticons/smile.pngYes - (but if you schema bind your tables and views, you can not drop dependent objects so this does appear to be the best of both worlds)Yes - yikes!NoGraphical Query/View Designer (e.g. you can see tables and select fields drag lines to do joins) included no additional charge.  As people pointedout there are lots of commercial and free tools that will do this for you.  We'll provide a listing and brief summary of features etc. of some of these in our product showcase later.Yes via SQL Management Studio and Studio Express and pretty nice.No Yes.  As of PgAdmin III 1.9, but its kind of hockey -- doesn't do JOINS right.Computed ColumnsYes - but we still like using Views more except when we really need the computed column indexed and often we just do triggers. Computed columns are of very limited use since they can't hold roll-ups.No - but looks like its slated for future releaseNo - but PostgreSQL has functional indexes so just use a view.Functional Indexes - indexes based on a functionNo - but you can create a computed column and create an index on itNoYesPartial Indexes - e.g. you want to create a unique index but only consider non-null valuesYes - as of SQL server 2008 See Tom's notesand called Filtered Indexes.NoYesACID compliance - do I dear say this is sometimes over-rated - not all data is created equal and sometimes bulk-insert speed is more important than ACIDYesSome storage engines e.g. InnoDB, PBXT(see comments from Giuseppe Maxia)and (not MyISAM)YesForeign Key - Cascade Update/DeleteYesInnoDB and not MyISAMYesMulti Row value insertYesYesYesUPSERT logic - where you can simultaneously insert if missing and update if presentYes via MERGE UPDATEYes - via INSERT IGNORE, REPLACEINSERT ON DUPLICATE UPDATENoReplication - haven't used much except for SQL Server so this is mostly hear-sayYes - all sorts - log shipping, mirroring, snapshot, transactional and merge etc. and can even have non-SQL Server windows-based subscribers.Its still a bear to get working the way you want it and makes making structural changes difficult.  Built-InYes - including master-master (built-in) See comments below and from numerours reports a big selling point of MySQL.Yes but from reports seems to be the least polished of the bunch, although numerours third-party options to choose from that are both free and non-free.  PostgreSQL 8.5 or higher isslated to have built-in replication.  Sorry guys this did not make it in. Slony is still used for replication, and many like it but find it finicky and harder to use than MySQL.Can program stored procs/functions in multiple languagesYes - In theory any language that complies with CLR -e.g VB.Net, C#, IronPython - but you need to compile into a dll first and then load the dll into the database.  The dll is stored as part of the database and the dependencies registered in the SQL Server GAC - a real PITA if you have lots of these dependencies than are non-standard.No (except C and Pl/SQL)Yes - PostgreSQL just does it the cool way (common ones PL/PgSQL, sql, PL/Python, PL/Perl, PL/R) - we like having our code right there where we can see what it is doing.  Downside server must host the language environment.  It now supports variadic functionssimilar to Oracle.  Neither MySQL nor SQL Server support that.Can define custom aggregate functionsYes - any .NET language, but not TRANSACT SQL. Why is Transact-SQL thrown out to dust like this?Yes but only in C as UDFYes - any PL language and built-in C, SQL, PLPgSQL.TriggersYesYesYesTable PartitioningYes - only Enterprise version - functional, rangeYesvia Table Inheritance, Constraint Exclusion, RULES and Triggers - basically RANGE.  Issues with using foreign-key constraints with inherited tablesin 8.4 the constraint_exclusion has anotheroption called "partition" which is the new default.  Which basically means you can have constraint_exclusion for partitioning and not have your other queries suffer.Can write Set/Table returning functions that can be used in FROM clauseYesNoYesSupport creation of functions - e.g. CREATE FUNCTIONYesYesYesSupport creation of stored procedures - e.g. CREATE PROCEDUREYesYesSort-Of - CREATE FUNCTION serves the same needDynamic and action SQL in functionsNo - but you can in Stored procedures but you can't call stored procs from SELECT statements so much more limiting than PostgreSQLNo, but can in Stored procedures which aren't callable from SELECT statements so more limiting than PostgreSQLYes! - you can do really cool things with action functions in SELECT statementsGraphical Explain Tool - no additional chargeYes - SQL Management Studio/ExpressNo (someone on Reddit mentioned maatkit visual explain for MySQL.  This is still a text format though and not quiteas pretty as SQL Server or PgAdmin III graphical explain plan. Are there others?Yes - PgAdmin IIIJob Scheduling Agent controllable from DB Manager client, for running batch sql and shell jobs - no additional charge (not CronTab)Yes - SQL Agent (not for Express), administer via Management Studio. Can do sql, sql maintainence plans, batch scripts, and SSIS work flows.  Its still the best. Has wizard for setting up maintenance plans.Yes -  though appears can only use it for MySQL sql calls.Yes- PgAgent and can run postgresql sql as well as batch scripts.  Administrated via PgAdmin III.Access tables from other databases on same serverYes - server.db.schema.table, can even access disparate data sources via linked server or open queryYes - db.table, but not easily across servers.  Across servers you need Federated storage engineSee  Rob Wultsch noteSort of - via Dblink, but much less elegant than MSSQL and MySQL way and much less efficient.  Can also access disparate data sources via DBI LinkCase-Insensitivity - e.g. LIKE 'abc%' and LIKE 'ABC%' mean the same thingBy default its not case sensitive, but can change this down to the column level.It is not case-sensitive by default but depends on character set (see comments from Giuseppe Maxia)By default is case-sensitive , but in 8.4 we have newer contrib citext integrated to define case insensitivity fields.Date Time supportFinally they support plain date -  Date, DateTime,DateTimeOffset. (Date and DateTimeOffset are new)Date and DateTime but none with Timezone, but you can have timezone, see Rob Wultschcomments.(Seems pretty much on par with SQL Server) - Not much changed - Date, TimeStamp and TimeStamp with Timezone (not to be confused with MySQL's timestamp which autoupdates or SQL Server's deprecated timestamp which is a binary).  Has Intervalwhich neither MySQL nor MS SQL Server have.AuthenticationStandard Db security and NT /Active Directory AuthenticationStandard Db with table-driven IP like securityExtensive - standard, LDAP, SSPI (can tie in with Active Directory if running on NT server, but still not quite as nice as SQL Server seamless integration), PAM, trust by IP, etc.Column Level PermissionsYesYesYes (introduced in 8.4)DISTINCT ONNoNoYesWITH ROLLUPYesYesNoWITH CUBEYesNoNoWindowing Functions OVER..PARTITION BYYesNoYes - and its way better than SQL Server 2008Common Table Expressions and Recursive queriesYesNoYesCOUNT(DISTINCT), AGGREGATE(DISTINCT)YesYesYesOGC Spatial Support - for the My dad is better than your dad fight in the GIS world between SQL Server and PostgreSQL/PostGIS check out A look at PostgreSQL and ArcSDE, Also check out our companion critque of the 3 spatial offeringsYes - now built-in, but we aren't allowed to provide benchmarks for obvious reasons.  If you use it, you'll really want to install the SQL Server 2008 Spatial Extension tools.  The upcoming SQL Server 2008 R2 (currently in CTP is supposed to have Report Builder with map integration features which should be interesting).  It has geodetic which PostGIS does not. SQL Server 2008 and PostGIS have pretty identical commercial support for spatial, but PostGIS still has a much larger Open source tool belt following.Yes - MBR mostly and spatial indexes only work under MyISAM.  Limited spatial functions. Some commercial (MapDotNet, Manifold.net), Open source GIS tools gaining steam but still more behind PostGIS.Yes - PostGIS is great and lots of spatial functions and fairly efficient indexing and lots of open source and commercial support - ESRI ArcGIS 9.3, MapInfo, Manifold, CadCorp, FME , no geodetic but expect thefirst version of geodetic in PostGIS 1.5, and fairly robust geodetic in PostGIS 2.0.SchemasYesNo (technically MySQL is implemented as a single db with schemas -- according the the information_schema schema, though in practice its not quite as clear cut as Oracle)YesCROSS APPLYYesNoNo but can for the most part simulate by putting set returning  functions in SELECT clause. As of 8.4, all set returning functionscan be used in the SELECT regardless of language it is written in.LIMIT .. OFFSETNo - has TOP  and ansi compliant ROW_NUMBER() OVER (ORDER BY somefield) As Row  --- where ..Row >= ... AND Row <= ... which is much more cumbersome to useYes (no ansi compliant way)Yes, and also supports the ansi compliant ROW_NUMBER() OVER (ORDER BY somefield)Advanced Database Tuning WizardYes - SQL Management Studio recommends indexes to put in etc. Very sweet.  NOT available for Express or Workgroup.NoNoMaintenance Plan WizardYes via SQL Management Studio - Workgroup and above. Very sweet.  Will walk you thru creating backup plan, reindexing plan, error checking and schedule these for you via SQL AgentNoNoPluggable Storage EngineNoYesNoCorrelated SubqueriesYesYesYesQuery Planner for complex queries (like doing correlated joins, lots of joins, lots of aggregates etc)-- the thing that figures out how to navigate data based on SQL Statement and histograms and stuff.  This is off the cuff ratingand varies based on kinds of queries you write.  For the joe blow blog or CMS or plain read SELECt ... FROM, this is probably not important and all 3 will perform adequately. We do a lot of statistical and financial apps where ability to run complex queries against millions of records in under 5 seconds is important.Moderate (but supports parallel processing out of the box). SucksOkay this was a spatial analysis and we can argue why beat a dead horse.  But this is just a bounding box query.Best.  PostgreSQL doesn't support parallel processing out of the box, but supports shared reads and with GridSQL (which we haven't tried), you do get parallelismFullText Engine - all 3 have it, but we don't feel right comparing since we haven't used each enough to make an authoritative comparison.  Its annoying there is no set standard for doing Full Text SQL queriesYesYesYesSequences /Auto NumberYes - via IDENTITY property of int fieldYes - via AUTO_INCREMENT of int fieldYes - via serial data type or defaulting to next Sequence of existing sequence object - this is better than MySQL and SQL Server simple auto_increment feature.  The reason it is better is that you can use thesame sequence object for multiple tables and you can have more than one per table. In the past PostgreSQL sequence was a pain but now you just create it with data type serial if youwant it to behave like SQL Server and MySQL and it will automatically drop the sequence if you drop the table it is bound to.Transactional DDL - ability to rollback CREATE, ALTER etc statementsYes (I couldn't find any documentation on this, but I tested it and it correctly rolls back).  There is a caveat that can't roll back DDL within a DDL trigger. NoYes - see this comparative analysis

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-220396-1-1.html 上篇帖子: 解决MSSQL 2008不能用IP登录的问题 下篇帖子: Visual Studio 2008 Express 中的 LINQ To SQL
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表