Posts

Showing posts with the label Halloween problem

SQL Server, execution plan and the lazy spool (clearly explained)

Image
Hi Guys, Welcome back! In one of the last posts we talked about Table Spool . We had explained what Spool are for by telling the somewhat curious story of the halloween problem . Here we specifically talked about a type of spool called Eager Spool   You can look to the execution plan below where the eager Spool is used to avoid the halloween problem in classic query of the "salary increase".. i suggest Well, if the story of the eager spool intrigued you, today instead we will speak about another type of Spool, the Lazy Spool . The Lazy spool Let's take a small step back. So, what is a Spool operation?  As we have already understood a spool operation is simply a temporary storage of data . Data are read from a source table and stored inside a worktable in the Tempdb database . While an Eager Spool is used to prevent the Halloween problem, the Lazy Spool is instead used to store data that will later be needed again when running a query . So, when a Lazy spool is used?  ...

A bit of theory of databases: The Halloween problem and the Table Spool

Image
Hi Guys, Welcome to this second post of the year. Today we will talk a little bit of theory, we will talk a little bit of database theory in general and therefore not specifically of our SQL Server. Enjoy yourselves!   The Halloween problem I don't know about you but " Halloween problem " makes me think of one of those old fairy tales that always hide a wise warning, one of those fairy tales lost in a past time which in our case is however the period in which relational databases were born and started to develop ... but let me tell you the whole story! This story begins around the mid-1970s. Ted Codd, a researcher working at IBM, had conceived relational databases a few years earlier. Also in those years both the idea of ​​ data normalization (who does not remember the third normal form learned at university?) And the ACID properties of transactions (we talked about it here) were born. It was the golden age of databases but at the same time pioneering! But let's go ...