4 ms·
> Adding a field in postgres while setting a default value would be exactly the same as adding a field Not true. Postgres locks the entire table for the durati
by pbiggar 15y ago
> Adding a field in postgres while setting a default value would be exactly the same as adding a field
Not true. Postgres locks the entire table for the duration of the update (which could be hours or days for a large enough dataset). Mongo will lock your entire databased for tiny fractions of a second, lots and lots of times. The difference is huge. The postgres implementation takes down your site, the Mongo implementation doesn't.
At scale, people start using Postgres a lot like a NoSQL service. Check out the Reddit schema for example, or read IMVU's blog posts on the topic (with MySQL, but same point). Or Facebook's architecture. All those migrations strategies look a lot more like mongo than postgres, even though they all use SQL DBs.
> Now I'm not anti-MongoDB, I'm just saying you shouldn't give it credit for something that relational database do just fine.
Saying "I can do NoSQL migrations just fine in Postgres" is like saying "I can do OO just fine in assembly".
- sausagefeet 15y agoAccording to the Postgres documentation, the behavior the poster a few levels up defined is possible in Postgres with no downtime. > When a column is added with ADD COLUMN, all existing rows in the table are initialized with the column's default value (NULL if no DEFAULT clause is specified). > Adding a column with a non-null default or changing the type of an existing column will require the entire table to be rewritten. This might take a significant amount of time for a large table; and it will temporarily require double the disk space. http://www.postgresql.org/docs/8.3/static/sql-altertable.html http://www.postgresql.org/docs/8.3/static/sql-altertable.htm...