Posts

Showing posts with the label TEMPDB

How to write performance queries! Take advantage of the Temporary Table Caching

Image
Hi Guys, I don’t usually talk about numbers but I have to say that almost 8000 clicks in just one month on my blog is really a huge amount! So, thanks to the 7000 k friends who follow me! In the last post (click here) we saw in detail how the tempDB database works. Today we see how to use what we learned to write in temporary tables as quickly as possible. In this way you can put your hand to your procedures to make them run ...and for free! Let’s see how to exploit the temporary table cache mechanism!  Enjoy! Temporary Table Caching In the previous post we saw that there are some rules to take advantage of the temporary table caching . We said that in the following cases table are not cached : Named constraints are not created DDL statements that affect the table are not run after the temporary table has been created.  for example the CREATE INDEX or CREATE STATISTICS statements Temp table is not created by using dynamic SQL Temp table is created inside another object,...

Why is my SQL Server so slow? TempDB & enhancements in SQL Server 2022.

Image
Hi Guys, Welcome back to this blog. Today we will talk about slowness . Qne of the most frequently asked questions is almost certainly: why is my SQL Server so slow? Today we will answer this question. But not only that. We will make a nice talk about the tempdb database to finally get to see what improvements SQL Server 2022 brings us on this front. Fasten your seat belts and enjoy the reading     W hy is my SQL Server so slow?     Let’s start by saying what is the TempDB database .   The TempDB database is a temporary system database even if its structure is essentially just like any other user database.  It is temporary in the sense that it is emptied every time the SQL Server instance is restarted . What exactly is written in the TempDB database? Well, first of all goes into the TempDD temp tables and table variables The creation of a temporary (#) table on a user database "IS A" creation of a table in the TempDB: Similarly ...the same thing happens wh...

SQL Server & Tempdb, configuration and benchmark

Image
Hi Guys, Welcome back! Topic of the Day is the TempDB database. We have already mentioned TempDB in some other posts such as: SQL Server & come spostare il database TEMPDB Il TEMPDB e la sua configurazione.. pronti per le Ferie? SQL Server 2019 ed il Memory-Optimized TempDB Metadata Using extended events to track the growth of the physical files that make up the tempDB database I'll show you some details! Ready? Create and extended event In order to show you some aspects of the tempdb database i will intercept the database_file_size_change event. First step I need to create an event session: CREATE EVENT SESSION [Whatis_inside_tempdb] ON SERVER ADD EVENT [sqlserver].[database_file_size_change] ( ACTION ( [sqlserver].[session_id], [sqlserver].[database_id], [sqlserver].[client_hostname], [sqlserver].[sql_text] ) WHERE ( [database_id] = ( 2 ) AND [session_id] > ( 50 ) ) ), ADD EVENT [sqlserver].[databases_log_file_used_size_cha...

SQL Server 2019 ed il Memory-Optimized TempDB Metadata

Image
Ciao a tutti! Oggi torniamo a parlare del database TEMPDB. Ne abbiamo già parlato altre volte in una serie di articoli che potete trovare qui: Confronto tra "Temp Tables" (#) e "Table Variables" (@)   Il TEMPDB e la sua configurazione.. pronti per le Ferie?   SQL Server & come spostare il database TEMPDB Cos’è il database TEMPDB? ...e quindi perché è importante. Questa volta però vi racconterò delle novità introdotte più di recente . Già perchè SQL Server con l'edizione 2019 introduce alcuni miglioramenti che sono davvero significativi in questo caso.   Memory-Optmized TempDB Metadata La feature Memory-Optmized TempDB Metadata di cui parlamiano oggi fa parte della famiglia di tecnologie dette In-Memory Database . Ma cosa significa Memory-Optmized TempDB Metadata? Cercherò di spiegarlo nel modo più semplice possibile! Dopo i numerosi articoli saprete sicuramente cos'è ed a che cosa serve il database TempDB. Sapete che è una risorsa c...

Confronto tra "Temp Tables" (#) e "Table Variables" (@)

Image
Ciao a tutti! Tempo fa mi avevano chiesto quali fossero le differenze tra le tabelle temporanee e le tabelle in memoria. Questo articolo l’ho scritto con l’intento di fare chiarezza! Spero di esserci riuscito. Oggi vi volevo presentare un confronto tra le tabelle temporanee (#) e le variabili di tipo tabella (@) .   Analizzeremo nel dettaglio le differenza tra questi due tipologie di tabelle per capire quando è meglio utilizzarne un tipo piuttosto che un altro.   Ma non solo, avrete occasione per vedere come leggere il log delle transazioni ed andremo anche a  sfruttare uno strumento che dovrà far parte della vostra “cassetta degli strumenti” e che utilizzeremo per generare il carico di lavoro parallelo necessario per la nostra analisi Parliamo di tabelle temporanee perché capita spesso nelle nostre elaborazioni di aver bisogno di una tabella “intermedia” sulla quale “appoggiare” i dati. SQL Server come dicevamo in apertura dell’articolo ...