We already take a bit of a performance hit on inserts to tables using IDENTITY columns. It's when we fetch the just-inserted value to put in  last_inserted_ids[]. The only way I can see to get the value of a just-inserted IDENTITY value in MSSQL is to issue the query:

  'SELECT @@IDENTITY'

immediately after the insert statement, so that's what the MSSQL module is doing now (it's connection-specific, so race-condition free).

I think MS-SQL 2005 has a new feature that will reflect column data on insert/update, kind of like the upcoming PG 'INSERT/UPDATE RETURNING' feature. Maybe someone with more time than me can take a look at this.

Rick

On 9/11/06, Michael Bayer <[EMAIL PROTECTED]> wrote:

On Sep 10, 2006, at 9:55 PM, Rick Morrison wrote:
> Oh, it gets even better. You can only have IDENTITY_INSERT on for
> one table at a time. Trying to set it on for another table while it
> is set on elsewhere will throw an error. It is necessary to turn it
> off first, then set it on for the other table.
>

Ok the "IDENTITY_INSERT" is only when you are inserting an *explicit*
value into an IDENTITY column, right ?  i would rather just allow
users to choose IDENTITY or not, using a flag on Column such as
"autoincrement=True".  obviously it defaults to True right now, but
for databases that cant handle switching (like ms-sql), you can turn
it off and get a non-IDENTITY column.  lets take that SET
IDENTITY_INSERT stuff out, thats not going to scale at all; it
appears that its intended for batch loads and isnt really appropriate
within an application flow.

Maybe, but I'd hate to lose the feature -- I'm already using it in some code, and there are some real-world (unusual, but real) use cases for it. Making it an optional feature would reduce the overhead to a fast check against a boolean for cases where it's turned off.
 


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Sqlalchemy-users mailing list
Sqlalchemy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to