SQL Server

/SQL Server

Deadlock Due To Bookmark Lookups

Deadlock Due To Bookmark Lookups In this blog post, we will see how deadlocks can happen in SQL Server due to Bookmark Lookups. Let’s create a dummy table WideWorldImporters & associated indexes. This will be our test data to play with. use WideWorldImporters GO -- create a opy of sales.customers select * into sales.customers2 from [...]

By |July 7th, 2020|SQL Server|Comments Off on Deadlock Due To Bookmark Lookups

Script: Find FillFactor of All Indexes in a Database

This blog post first appeared on SQLMaestros In our previous blog posts, we have seen how to find fragmented indexes in a database and how to defrag them by using rebuild/reorganize. While creating or rebuilding indexes, we can also provide an option called “FILLFACTOR” which is a way to tell SQL Server, how much percentage [...]

By |July 6th, 2020|Scripts, SQL Server|Comments Off on Script: Find FillFactor of All Indexes in a Database

Script: How to Defragment All The Indexes In a Database

This blog post first appeared on SQLMaestros In our previous blog post, we got to know, how to find out all fragmented indexes in a database. Now we will see how to defrag indexes. According to Microsoft guidelines, based upon index fragmentation percentage, we may choose to either REORGANIZE, REBUILD indexes or just ignore. Here [...]

By |July 3rd, 2020|Scripts, SQL Server|Comments Off on Script: How to Defragment All The Indexes In a Database

Script: Find The Fragmented Indexes In A Database

This blog post first appeared on SQLMaestros We do create indexes to improve the search performance of our queries. But over a period of time, because of DML operations (inserts/deletes/updates), the data will get spread across the disc (Physical order of pages are NOT in sequence). This is called fragmentation. Watch this video by @A_Bansal [...]

By |July 2nd, 2020|Scripts, SQL Server|Comments Off on Script: Find The Fragmented Indexes In A Database

Script: Find Tables Without Clustered Index

This blog post first appeared on SQLMaestros Before we start fine tuning SQL Server, it is good to make sure all basic best practices are in place. One such best practice is to have a clustered index on every table in the database (well, not always but most of the times, having clustered index per [...]

By |July 2nd, 2020|Scripts, SQL Server|Comments Off on Script: Find Tables Without Clustered Index

Faster INSERTs in Tempdb – Optimized/Minimal Tempdb Logging

This blog post first appeared on SQLMaestros . Faster INSERTs in Tempdb – Optimized/Minimal Tempdb Logging In this blog post, we will see how SQL Server optimises Tempdb logging for faster CRUD operations. For the purpose of this tutorial, we will perform the same operations in a regular user database versus Tempdb, and note down [...]

By |July 2nd, 2020|SQL Server|Comments Off on Faster INSERTs in Tempdb – Optimized/Minimal Tempdb Logging

SARGABILITY, CAST, CONVERT & More…

This blog post first appeared on SQLMaestros . The phrase Sargability is quite popular in SQL Server world. Wikipedia says: “In relational databases, a condition (or predicate) in a query is said to be sargable if the DBMS engine can take advantage of an index to speed up the execution of the query. The term [...]

By |July 2nd, 2020|SQL Server|Comments Off on SARGABILITY, CAST, CONVERT & More…