“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 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 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 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 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 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 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 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 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 ArticleSCHEMABINDING 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 Articleינואר 2018 –קידום אישי ומקצועי
בכל אחד ואחת מאיתנו קיים הצורך בלמידה מתמדת. הן בתחומים שיקדמו אותנו בעבודה והן בנושאים אחרים. מקום העבודה, המקום בו אנחנו נמצאים שליש מהיום שלנו לפחות, יכול להוות מעטפת תומכת ומקדמת גם באזורים...
View ArticleHow to Troubleshoot Waiting Tasks Without Requests in SQL Server?
Usually, when I need to troubleshoot currently running requests, I use a combination of sys.dm_exec_requests and sys.dm_os_waiting_tasks. The former retrieves all the current requests, whether they are...
View ArticleDoing More with Less – My Productivity Guide
Houston, We Have a Problem We are living in a crazy world. And it just gets more and more crazy all the time. The amount of tasks we are confronted with at any given point in time is crazy. The...
View ArticleHow to Size Your Database Files?
Let’s say you need to create a new SQL Server database, which is going to grow very fast, but you don’t know how fast. What would be the initial size of the data file? On one hand, you want to make...
View ArticleWhat is Graph Processing in SQL Server 2017?
There is a growing need for Graph Databases in the market. This is a type of database, which is capable of storing, representing and manipulating graphs easily and efficiently. Common use cases for...
View ArticleHow to fix Orphaned Users easily
What are Orphaned Users “Orphaned Users” is a common issue in SQL Server where a Database User is no longer associated with its relevant Server Login. This often happens when the Server Login is...
View ArticleHow to troubleshoot database mail?
If after creating a profile and account you send a test email and it doesn’t work try this: Check the database mail log if it is empty: “SELECT * FROM msdb.dbo.sysmail_event_log;” Check mail status is...
View ArticleWhat is the Automatic Plan Correction in SQL Server 2017?
SQL Server 2017 brings a new interesting feature, that might be a game changer in some environments. I’m talking about Automatic Plan Correction. This feature automates the on-going tuning process of...
View ArticleSQL Saturday Nepal 2017
I had the honor to visit Nepal and participate in SQL Saturday Nepal 2017. You can visit the event website here. I presented a session about “How to Use Parameters Like a Pro and Boost Performance”....
View ArticleHow to Update @@SERVERNAME to Actual Machine Name?
The @@SERVERNAME Global Variable The system global variable @@SERVERNAME can be used to return the name of the machine the SQL Server is hosted on. This variable is derived from the system table...
View Article