Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Post History
Despite the fact that I have programmed against SQL Server for quite a while I did not pay much attention to the tempdb database. This is especially true if application logic is mostly written usin...
#2: Post edited
- Despite the fact that I have programmed against SQL Server for quite a while I did not pay much attention to the `tempdb` database. This is especially true if application logic is mostly written using the ORM instead of stored procedure.
- However, I have just realized that the SQL Server architecture is pretty strange in that the `tempdb` is a single database shared by all the other databases within the instance. Under heavier loads this can lead to performance issues as mentioned [here](https://www.brentozar.com/blitz/tempdb-data-files/) or [here](https://logicalread.com/3-things-sql-server-tempdb-performance-pd01/).
I am wondering about what is the rationale of having a single special database for temporary tables (and other temporary objects to hold "spilled data"). Why not simply use another "space" (e.g. schema) within the database where the query runs? This would certainly ensure a better isolation between databases activity within the same instance.- I tried to find the reasons for such a design decision, but perhaps it was decided such a long time ago that nobody argues about it now.
- Despite the fact that I have programmed against SQL Server for quite a while I did not pay much attention to the `tempdb` database. This is especially true if application logic is mostly written using the ORM instead of stored procedure.
- However, I have just realized that the SQL Server architecture is pretty strange in that the `tempdb` is a single database shared by all the other databases within the instance. Under heavier loads this can lead to performance issues as mentioned [here](https://www.brentozar.com/blitz/tempdb-data-files/) or [here](https://logicalread.com/3-things-sql-server-tempdb-performance-pd01/).
- I am wondering about what is the rationale of having a single special database for temporary tables ([and others](https://logicalread.com/sql-server-internals-tempdb/)). Why not simply use another "space" (e.g. schema) within the database where the query runs? This would certainly ensure a better isolation between databases activity within the same instance.
- I tried to find the reasons for such a design decision, but perhaps it was decided such a long time ago that nobody argues about it now.
#1: Initial revision
Is there any justification for having a single tempdb database to be used by all databases on a SQL Server intstances?
Despite the fact that I have programmed against SQL Server for quite a while I did not pay much attention to the `tempdb` database. This is especially true if application logic is mostly written using the ORM instead of stored procedure. However, I have just realized that the SQL Server architecture is pretty strange in that the `tempdb` is a single database shared by all the other databases within the instance. Under heavier loads this can lead to performance issues as mentioned [here](https://www.brentozar.com/blitz/tempdb-data-files/) or [here](https://logicalread.com/3-things-sql-server-tempdb-performance-pd01/). I am wondering about what is the rationale of having a single special database for temporary tables (and other temporary objects to hold "spilled data"). Why not simply use another "space" (e.g. schema) within the database where the query runs? This would certainly ensure a better isolation between databases activity within the same instance. I tried to find the reasons for such a design decision, but perhaps it was decided such a long time ago that nobody argues about it now.