|
From: Trevor C. <pr...@se...> - 2003-10-20 21:44:40
|
<me> auto-increment just allows to read in the actual id afterwards This is not reliable for concurrent inserts (which is why I generally = use sequences) </me> <juergen>=20 This is not reliable even with proper transactions? Shouldn't = "last_insert_id" or whatever it is called return the last inserted id in = the same transaction, allowing for concurrent inserts in different = transactions? </juergen> With transactions it should function properly. The problem is that with = transactions you have different locking strategies which have different = performance trade-offs depending on the level used. I've found that = using identity type fields makes transactions and specific locking = strategies required. By using a sequence, I can choose different = transaction/locking strategies depending on requirements/performance = (using the identity seems to limit my options). Also, it's generally a lot harder to change the db (especially the = primary key) after it's in production. I can do anything I want with = sequences, but I have more limited options with identity. If they work = today but not tomorrow, it's no longer a simple code change (and getting = burned by this a few times made me change to sequences as a default). = That's just my experience/preference. As I mentioned though, in this = case it should work correctly, and since it's a sample app changing the = db later is perfectly acceptable. Sorry I took us a little off-topic. Trevor |