On 2017/11/24 5:23 AM, Peter Halasz wrote:
As for whether I need to use AUTOINCREMENT, it seemed like a good idea to
avoid rowid reuse, but I can avoid using it for the sake of optimization,
so probably will.

I agree with Keith and has many times mentioned this before (apologies to others for the déjà vu). You as the programmer / designer should always be in control of how and why a new ID is assigned.

It feels like a saving to let the DB engine do it for you, but it isn't really. What you save in a bit of code that decides the new ID before-hand (which can be as simple as SELECT MAX(id)+1 FROM t) you typically have to catch up afterward in code to do the usual get-LastInsertedID and then pop that in wherever stuff wants to link to the new item. It's a zero-sum gain really.

I'm not even a big fan of Integer IDs, I think codes / UUIDs are best, but obviously the speed/size gain with an integer key (especially INTEGER PRIMARY KEY row-id alias in SQLite) can't be ignored.

Disclaimer: This is only my opinion, well, I'm not completely alone in it, but it is still an opinion and not a general SQL prescription.


_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to