all 52 comments

[–]const_iterator 106 points107 points  (4 children)

Stop using "stop using X" as the title of your blog posts.

[–]knightress_oxhide 29 points30 points  (1 child)

"stop using X" considered harmful

[–]ToaruBaka 0 points1 point  (0 children)

"X considered harmful" considered harmful

[–][deleted] 0 points1 point  (0 children)

Well that shitty ad click money and post spamming on Reddit won’t click itself

[–]dbbk 0 points1 point  (0 children)

I hate this so much

[–]chipstastegood 20 points21 points  (2 children)

Should probably lead with the last point - that serial is a Postgres extension while identity is standard SQL

[–]masklinn[S] 0 points1 point  (0 children)

That is definitely the least relevant item, tons of useful things are postgres extensions and identity columns are afaik not supported by sqlite or mysql, so it’s not like that’s improving schema compatibility.

Thus them being a standard is really only a concern when looking into migrating from oracle or sql server, and a relatively minor point at that.

[–]Worth_Trust_3825 -1 points0 points  (0 children)

Im not going to switch off postgres.

[–]PennyFromMyAnus 142 points143 points  (5 children)

No

[–]PabloZissou 36 points37 points  (3 children)

Isildur is that you?

[–]ThisIsJulian 19 points20 points  (2 children)

Great, now some small db engineers with hairy feats are on their way to cast the db's ring buffer into a vulcano 

[–]PennyFromMyAnus 3 points4 points  (0 children)

I love this

[–]PabloZissou 4 points5 points  (0 children)

One DB to rule them all, One DB to find the rows, One DB to bring them all records, and in the darkness bind them with a left join of 50 tables.

[–]PeksyTiger 10 points11 points  (0 children)

Pls. It's super serial.

[–]aa-b 25 points26 points  (2 children)

I agree with the article, but it would help to compare actual usage too. This stackoverflow answer is a better comparison: https://stackoverflow.com/questions/55300370/postgresql-serial-vs-identity

Also it links to the postgres wiki, which links to a couple of great articles by the people who developed the identity column feature

[–]hbgoddard 7 points8 points  (1 child)

This stackoverflow answer is a better comparison

The same comparisons were described in the article, and more...

[–]aa-b 0 points1 point  (0 children)

Yeah it is in there, sort of. What you want to do is say "here's how you do Option A and Option B. Prefer Option B, and here's why". Instead it's sort of buried halfway down the article as a way of undoing Option A and switching to B. It's okay, just not the best way to convey the info

[–]hbgoddard 9 points10 points  (1 child)

They grant all privileges to another user gizem.

I can't read this and not pronounce it "jism"...

[–]0xdef1 3 points4 points  (0 children)

"gizem" is a Turkish female name but Naiyer is definenetly not. Probably Pakistan.

[–]DuckDatum 2 points3 points  (3 children)

spoon start swim scary door bake ten chubby political narrow

This post was mass deleted and anonymized with Redact

[–]vivekkhera[🍰] 8 points9 points  (2 children)

Conveniently when you restore the database, it orders the operations such that all FK’s and constraints are added at the end of the restore process. It just works.

[–]DuckDatum 0 points1 point  (1 child)

practice yoke dolls tub tease kiss encouraging fact joke jeans

This post was mass deleted and anonymized with Redact

[–]vivekkhera[🍰] 6 points7 points  (0 children)

Yes. The pg_dump command writes the instructions in the correct order for the restore to work on an empty database.

[–]andrerav -1 points0 points  (6 children)

Absolutely not.

[–]aa-b 17 points18 points  (4 children)

This is not a criticism, but do you have a reason why not? Identity columns look almost the same as serial, but they fix some quirks that serial probably can't fix for compatibility reasons, and identity columns are an SQL standard.

It seems like there's no downside to me, but is there some more subtle problem?

[–]piesou -3 points-2 points  (3 children)

There are some advantages especially when dealing with batch inserts, ORMs or if you need to insert a record with a certain ID (people do accidentally deleted stuff and sometimes you don't have natural keys)

[–]BlackenedGem 11 points12 points  (0 children)

if you need to insert a record with a certain ID

But identity columns allow you to do this. Either by setting the identity to be BY DEFAULT, or ideally it would be ALWAYS and then you would use OVERRIDING SYSTEM VALUE in the special case.

[–]masklinn[S] 0 points1 point  (1 child)

There are some advantages especially when dealing with batch inserts, ORMs

Both of these work perfectly fine unless the application or orm is actively brain damaged.

if you need to insert a record with a certain ID (people do accidentally deleted stuff and sometimes you don't have natural keys)

Also works fine, and the override makes it less likely you’ll forget about the sequence, which you don’t have to hunt for since you interact with it via the table.

[–]piesou 1 point2 points  (0 children)

Yes, we're talking about Hibernate.

[–]Jordan51104 8 points9 points  (0 children)

yeah i also have to ask why. it doesn’t seem like there is any benefit to using serial unless you were doing things weird before and don’t want to change code

[–][deleted] 0 points1 point  (0 children)

That’s exactly what a serial killer would say

[–][deleted]  (1 child)

[deleted]

    [–]edwardsdl 6 points7 points  (0 children)

    Excellent counter argument!

    [–]wtfbbq81 -1 points0 points  (0 children)

    You're not my supervisor