Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Moving from mysql to postgresql, best features I was missing?

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?

like image 339
arthurprs Avatar asked Feb 17 '11 00:02

arthurprs


People also ask

Is it easy to migrate from MySQL to PostgreSQL?

To connect MySQL to PostgreSQL through Foreign Data Wrapper, you must take note of the following as this is what will be required to create the connection: CREATE EXTENSION command to create a MySQL Foreign Data Wrapper extension to the PostgreSQL host. CREATE SERVER command to define a connection to the MySQL Server.

Is it possible to migrate from MySQL to PostgreSQL?

MySQL-to-PostgreSQL is a program to migrate MySQL databases to PostgreSQL server. Option to filter data using SELECT-queries, synchronization mode, command line support. FromMySqlToPostgreSql migration tool by Anatoly Khaytovich, provides an accurate migration of table data, indices, PKs, FKs...

Why we use PostgreSQL instead of MySQL?

The Critical Differences of Postgres vs MySQL:MySQL is a simpler database that's fast, reliable, well understood, and easy to set up and manage. PostgreSQL is an object-relational database (ORDBMS) with features like table inheritance and function overloading, whereas MySQL is a pure relational database (RDBMS).


2 Answers

  • One of the nicest feature of

    • Postgresql is index on expression:
    • http://www.postgresql.org/docs/9.0/interactive/indexes-expressional.html
    • http://www.ienablemuch.com/2010/12/postgresql-speeding-up-slow-coalesce.html
  • User-defined aggregates:

    • http://developer.postgresql.org/pgdocs/postgres/xaggr.html
    • How to query sum previous row of the same column with with pgSql
    • http://www.ienablemuch.com/2011/02/how-to-find-second-best-grade-of_06.html
  • CTE, supports recursion

    • http://www.ienablemuch.com/2010/04/simple-hierarchical-query-display.html
  • generate_series

    • http://www.ienablemuch.com/2010/12/date-functions.html
  • Windowing functions:

    • http://www.ienablemuch.com/2011/01/postgresql-lag-windowing-function.html
  • Superb date functions

    • http://www.ienablemuch.com/2010/12/finding-previous-day-of-week.html
  • Array support

    • http://www.ienablemuch.com/2010/12/any-clause-is-superior-to-in-clause-at.html
    • http://www.ienablemuch.com/2010/05/postgresql-users-are-spoiled-with.html
  • Richer data types

    • http://www.ienablemuch.com/2010/05/varchar-ip-address-sorting.html
  • Functional dependency on primary keys when grouping on it (on next version, 9.1)

    • http://www.ienablemuch.com/2010/08/postgresql-recognizing-functional.html
  • User-defined operator

    • Adding sum of current_timestamp and days column in Postgres
  • DISTINCT ON

    • How to get the parent given a child in SQL SERVER 2005
  • LATERAL JOIN

    • http://www.anicehumble.com/2013/09/sql-server-said-postgresql-said-apply-lateral.html
  • Custom data type using DOMAIN

    • http://www.sqlines.com/postgresql/how-to/create_user_defined_type
  • Passing the whole row to function

    • SQL SELECT statement expression value reuse for other expression
like image 112
Michael Buen Avatar answered Oct 12 '22 12:10

Michael Buen


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.

like image 38
Frank Heikens Avatar answered Oct 12 '22 13:10

Frank Heikens