8

I used to develop everything with mysql, this week an opportunity to work with postgresql appeared, why not!

I was always told that postgresql had a much bigger feature set.
I read some wikis, but most of the info are really outdated.

What are the best features I was missing? Like partial indexes, etc..
Also, I will miss something from mysql?

arthurprs
  • 4,457
  • 3
  • 26
  • 28

5 Answers5

19
Michael Buen
  • 38,643
  • 9
  • 94
  • 118
  • It would be really nice/helpful if you could talk a little bit about why you like "index on expression", "user defined aggregates", "richer datatypes", "array support", etc.. and how you've used those in the past – arnorhs Feb 17 '11 at 01:01
  • Dude, I'm scared! Literally! There are some things that I never thought was possible to do within an query! There are other other "easier to use" features? – arthurprs Feb 17 '11 at 01:08
  • I think I explained them how are they useful(on the articles(my blog)). I'll expound them here later, I need go to office now, I'll be late, it's 9:09 AM already :-) – Michael Buen Feb 17 '11 at 01:09
  • 1
    I"m not a fan of the functional dependency when grouping on the PK. MySQL has a similar feature and I wish no DB vendor implemented it. Far better to be explicit about how it is choosing the other fields not referenced in Group By clause even if the Group By column is a PK. – Thomas Feb 17 '11 at 05:11
  • However, I must say that some of the features, namely the windowing functions, would be nice. Many have long asked for that in SQL Server. – Thomas Feb 17 '11 at 05:14
  • 1
    @Thomas: MySQL doesn't check anything, that's not the same as functional dependency on the primary key. Just download an alfa release of 9.1 and see the difference between both implementations. – Frank Heikens Feb 17 '11 at 07:48
  • generate_series() is just fantastic ;) –  Feb 17 '11 at 22:53
  • 2
    @MichaelBuen: excellent list! You could add `DOMAIN`s ; extremely useful wrt constraint minimisation. (and standard, as opposed to UDTs) – wildplasser Aug 10 '13 at 17:43
  • 1
    Add LATERAL JOIN to the list. – Joel Coehoorn Jan 30 '18 at 21:17
7

And don't forget the DDL, it's also transaction safe:

BEGIN;
  ALTER TABLE foo DROP COLUMN bar;
  ALTER TABLE foo ADD COLUMN baz INET;
COMMIT;

Great for maintenance work, you will always have a consistent database, even when you lose the database connection or the server goes down.

Frank Heikens
  • 117,544
  • 24
  • 142
  • 135
7

In addition to Michael's list (of which I like windowing functions the most)

  • check constraints
  • table functions (functions that can be used in like this select * from my_func(42)
  • partial index (CREATE INDEX idx1 ON some_table (some_column) WHERE some_flag = true)
  • division by zero is an error
  • delete from some_table where 42 is considered an error and doesn't delete the whole table
  • you can have a subquery in an UPDATE or DELETE that selects from the same table as you are updating
  • much smarter query optimizer
  • deferrable constraints (seldomly used, but when you need them, they are really helpful)
  • foreign keys are evaluated for the whole statement not row by row
  • full text search and spatial extensions on transactional tables
  • EXCEPT
  • The check constraints are extremely useful. I think MINUS is in oracle, it's EXCEPT in postgresql. – arthurprs Feb 17 '11 at 22:49
  • @Arthur: Thanks, you are right. EXCEPT is the standard and that's what PG uses. –  Feb 17 '11 at 22:52
3

Here's a link that lists out the difference in features between many of the major database products:

Comparison of different SQL implementations

Thomas
  • 63,911
  • 12
  • 95
  • 141
1

FULL OUTER JOINs. The lack of these is one of my biggest complaints about MySQL. But Postgresql supports them.