Should I commit or rollback a transaction that creates a temp table, reads, then deletes it?

Posted by Triynko on Stack Overflow See other posts from Stack Overflow or by Triynko
Published on 2010-05-21T00:54:38Z Indexed on 2010/05/21 1:00 UTC
Read the original article Hit count: 308

To select information related to a list of hundreds of IDs... rather than make a huge select statement, I create temp table, insert the ids into it, join it with a table to select the rows matching the IDs, then delete the temp table. So this is essentially a read operation, with no permanent changes made to any persistent database tables.

I do this in a transaction, to ensure the temp table is deleted when I'm finished. My question is... what happens when I commit such a transaction vs. let it roll it back?

Performance-wise... does the DB engine have to do more work to roll back the transaction vs committing it? Is there even a difference since the only modifications are done to a temp table?

Related question here, but doesn't answer my specific case involving temp tables: http://stackoverflow.com/questions/309834/should-i-commit-or-rollback-a-read-transaction

© Stack Overflow or respective owner

Related posts about transaction

Related posts about sql-server-2008