mpy
mpy

Reputation: 632

Querying a database would use tempdb files or database log file?

I am new to SQL Server and have a basic question: querying SQL Server

For ex : databasetest would use and fill its database log file (databasetest_log) or tempdbs' primary or log file?

Upvotes: 0

Views: 36

Answers (1)

Dan Guzman
Dan Guzman

Reputation: 46203

The database transaction log records modifications to support commit and rollback. SELECT queries do not use the database log since these do not modify data.

SELECT queries might use tempdb (data and log) depending on the execution plan (e.g. for sorting) or for a row-versioning isolation level to provide read-consistency.

DDL (e.g. CREATE statements) and data modification statements (INSERT, UPDATE, DELETE, MERGE) will use the database transaction log. These might also use tempdb similarly to SELECT statements depending on the execution plan or if row-versioning is needed.

Upvotes: 2

Related Questions