SCHEMABINDING and Why It Can be Useful?
In SQL Server, when we use the “WITH SCHEMABINDING” clause in the definition of an object (view or function), we bind the object to the schema of all the underlying tables and views. This means that...
View ArticleExtremely easiest tricks to list table column names and replace SELECT *
Everyone know simple T-SQL “SELECT * ” bad practice. It’s: – Effect on the execution plan (Table / Index Scan); – Returning too much data (unnecessary extra reads, memory grant, increases network...
View ArticleThe king is dead, long live the king!
Everyone, who deal with SQL server, know sample database AdventureWorks, which has been with us since the days of SQL Server 2005. Most of official SQL Server documentation, third-party educational...
View ArticleWhy we should enable trace flag 3604 before part of DBCC statements?
In many cases, while we using DBCC commands, we must to run two statements instead of one, in order to receive the wishful result. For example, in order to receive database information, we write:...
View ArticlePlanning to Increase Cost Threshold for Parallelism – Like a Smart Person!
Planning to Increase Cost Threshold for Parallelism When administrating a SQL Server instance with multiple CPU cores and heavy workload, it’s common to see SQL Server creating and using execution...
View ArticleUse Filtered Statistics to Improve Performance on Very Large Tables
Let’s say you have a very large table on a SQL Server 2012 Standard Edition instance. This means: old cardinality estimator and no partitioning. The table has a DATETIME column, which is...
View ArticleWhat is the CXPACKET Wait Type?
This wait type indicates that parallel plans execute on the server. This wait type doesn’t necessarily means there is a problem. It only points to the existence of parallelism. In many systems, this...
View ArticleCreating AlwaysOn Availability Group With Scripts
One day, your Availability Group cluster can get into a critical state in a way that forces your team to create the Availability Group from scratch. The following scripts can save you’re A$$ and...
View ArticleWhich One is Better? IN or BETWEEN?
I just had an interesting case of performance tuning: a query with multiple predicates on a very large table. Something like this: SELECT ... FROM dbo.LotsOfEvents WHERE EventType BETWEEN 1 AND 3 AND...
View Article“Last Known Good” or why after instance restart CHECKDB ends so fast?
After every restart of SQL server instance, we can find in the error log messages like: CHECKDB for database ‘AdventureWorks2017’ finished without errors on … (local time). Usually, we wait hours for...
View Article