Sign in
Craig Freedman's SQL Server Blog
A discussion of query processing, query execution, and query plans in SQL Server.
Options
About
Email Blog Author
RSS for Posts
Atom
RSS for Comments
OK
Search
Advanced search options...
Search In:
Everything
Blogs
Forums
People
Groups
Places
Pages
Date range:
All Time
Last Year
Last 6 Months
Last 3 Months
Last Month
Last Week
Last Two Days
Search
Tags
Aggregation
Common Table Expressions
Conversions
Hints
I/O
Isolation Levels
Joins
Parallelism
Partitioned Tables
Pivot and Unpivot
Ranking Functions
Rollup and Cube
Scans and Seeks
Subqueries
Top
Updates
Archive
Archives
January 2010
(1)
July 2009
(1)
June 2009
(1)
April 2009
(1)
March 2009
(2)
February 2009
(1)
October 2008
(2)
September 2008
(1)
August 2008
(2)
July 2008
(1)
June 2008
(2)
May 2008
(2)
April 2008
(1)
March 2008
(2)
February 2008
(1)
January 2008
(2)
November 2007
(1)
October 2007
(3)
September 2007
(3)
August 2007
(3)
July 2007
(4)
June 2007
(2)
May 2007
(5)
April 2007
(2)
December 2006
(1)
November 2006
(4)
October 2006
(4)
September 2006
(4)
August 2006
(5)
July 2006
(4)
June 2006
(6)
MSDN Blogs
>
Craig Freedman's SQL Server Blog
Posts
Subscribe via RSS
Sort by:
Most Recent
|
Most Views
|
Most Comments
Excerpt View
|
Full Post View
Craig Freedman's SQL Server Blog
More on Implicit Conversions
Posted
Wed, Jan 20 2010
by
craigfr
0
Comments
Yesterday, a reader posted a question asking me to comment on SQL Server's algorithm for choosing implicit conversions. When SQL Server encounters an expression with mismatched types, it has two options. It can execute the query with an implicit conversion...
Craig Freedman's SQL Server Blog
Correction to my prior post on sys.dm_db_index_operational_stats
Posted
Wed, Jul 29 2009
by
craigfr
2
Comments
In this post about the sys.dm_db_index_usage_stats and sys.dm_db_index_operational_stats DMVs, I wrote: Another less important difference between these DMVs is that sys.dm_db_index_usage_stats only reports on indexes that have been used at least once...
Craig Freedman's SQL Server Blog
Maximum Row Size and Query Hints
Posted
Wed, Jun 24 2009
by
craigfr
0
Comments
In my last post (yes, that was two months ago), I gave an example of how a query hint could cause a query to fail. In this post, I'll give another example of how query hints can cause problems. As with my last post, this post was inspired by a question...
Craig Freedman's SQL Server Blog
Implied Predicates and Query Hints
Posted
Tue, Apr 28 2009
by
craigfr
5
Comments
In this post, I want to take a look at how two seemingly unrelated features of SQL Server can interact to cause a problem. The idea for this post came from a question submitted by a reader. Let's begin. Consider the following trivial schema and query...
Craig Freedman's SQL Server Blog
OPTIMIZED Nested Loops Joins
Posted
Wed, Mar 18 2009
by
craigfr
2
Comments
In my past two posts, I explained how SQL Server may add a sort to the outer side of a nested loops join and showed how this sort can significantly improve performance . In an earlier post , I discussed how SQL Server can use random prefetching to improve...
Craig Freedman's SQL Server Blog
Optimizing I/O Performance by Sorting – Part 2
Posted
Wed, Mar 4 2009
by
craigfr
2
Comments
In my last post, I discussed how SQL Server can use sorts to transform random I/Os into sequential I/Os. In this post, I'll demonstrate directly how such a sort can impact performance. For the following experiments, I'll use the same 3 GByte database...
Craig Freedman's SQL Server Blog
Optimizing I/O Performance by Sorting – Part 1
Posted
Wed, Feb 25 2009
by
craigfr
4
Comments
In this post from last year, I discussed how random I/Os are slower than sequential I/Os (particularly for conventional rotating hard drives). For this reason, SQL Server often favors query plans that perform sequential scans of an entire table over plans...
Craig Freedman's SQL Server Blog
What is the difference between sys.dm_db_index_usage_stats and sys.dm_db_index_operational_stats?
Posted
Thu, Oct 30 2008
by
craigfr
6
Comments
SQL Server includes two DMVs - sys.dm_db_index_usage_stats and sys.dm_db_index_operational_stats - that are extremely useful for monitoring which indexes are used as well as how and when they are used. Both DMVs report similar statistics on information...
Craig Freedman's SQL Server Blog
Random Prefetching
Posted
Tue, Oct 7 2008
by
craigfr
1
Comments
In my last post , I explained the importance of asynchronous I/O and described how SQL Server uses sequential read ahead to boost the performance of scans. In this post, I'll discuss how SQL Server uses random prefetching. Let's begin with a simple example...
Craig Freedman's SQL Server Blog
Sequential Read Ahead
Posted
Tue, Sep 23 2008
by
craigfr
9
Comments
Balancing CPU and I/O throughput is essential to achieve good overall performance and to maximize hardware utilization. SQL Server includes two asynchronous I/O mechanisms - sequential read ahead and random prefetching - that are designed to address this...
Craig Freedman's SQL Server Blog
Dynamic Partition Elimination Performance
Posted
Fri, Aug 22 2008
by
craigfr
1
Comments
In this post on partitioned tables, I mentioned that SQL Server 2008 has a much more efficient implementation of dynamic partition elimination as compared to SQL Server 2005. In response, a reader posted this comment asking how much dynamic partition...
Craig Freedman's SQL Server Blog
Partitioned Indexes in SQL Server 2008
Posted
Tue, Aug 5 2008
by
craigfr
1
Comments
In my last post , I looked at how SQL Server 2008 handles scans on partitioned tables. I explained that SQL Server 2008 treats partitioned tables as tables with a logical index on the partition id column and that SQL Server 2008 implements partition elimination...
Craig Freedman's SQL Server Blog
Partitioned Tables in SQL Server 2008
Posted
Tue, Jul 15 2008
by
craigfr
10
Comments
In this post , I introduced how SQL Server 2005 implements query plans on partitioned tables. If you've read that post or used partitioned tables, you may recall that SQL Server 2005 uses a constant scan operator to enumerate the list of partition ids...
Craig Freedman's SQL Server Blog
Subqueries in BETWEEN and CASE Statements
Posted
Fri, Jun 27 2008
by
craigfr
5
Comments
Consider the following query: CREATE TABLE T1 (A INT, B1 INT, B2 INT) CREATE TABLE T2 (A INT, B INT) SELECT * FROM T1 WHERE (SELECT SUM(T2.B) FROM T2 WHERE T2.A = T1.A) BETWEEN T1.B1 AND T1.B2 Observe that the subquery in this query only needs to be evaluated...
Craig Freedman's SQL Server Blog
Implicit Conversions
Posted
Thu, Jun 5 2008
by
craigfr
4
Comments
In my last couple of posts, I wrote about how explicit conversions can lead to errors. In this post, I'm going to take a look at some issues involving implicit conversions. SQL Server adds implicit conversions whenever you mix columns, variables, and...
Craig Freedman's SQL Server Blog
Query Processing Presentation
Posted
Thu, May 15 2008
by
craigfr
0
Comments
Last week, I had the opportunity to talk to the New England SQL Server Users Group . I would like to thank the group for inviting me, Adam Machanic for organizing the event, and Red Gate for sponsoring it. My talk was an introduction to query processing...
Craig Freedman's SQL Server Blog
Conversion and Arithmetic Errors: Change between SQL Server 2000 and 2005
Posted
Tue, May 6 2008
by
craigfr
0
Comments
In this post from last week, I gave an example of a query with a conversion where the optimizer pushes the conversion below a join. The result is that the conversion may be run on rows that do not join which could lead to avoidable failures. I ran this...
Craig Freedman's SQL Server Blog
Conversion and Arithmetic Errors
Posted
Mon, Apr 28 2008
by
craigfr
4
Comments
Let's take a look at a simple query: CREATE TABLE T1 (A INT, B CHAR(8)) INSERT T1 VALUES (0, '0') INSERT T1 VALUES (1, '1') INSERT T1 VALUES (99, 'Error') SELECT T1.A, CONVERT(INT, T1.B) AS B_INT FROM T1 There is no way to convert the string "Error" into...
Craig Freedman's SQL Server Blog
Ranking Functions: RANK, DENSE_RANK, and NTILE
Posted
Mon, Mar 31 2008
by
craigfr
3
Comments
In my previous post , I discussed the ROW_NUMBER ranking function which was introduced in SQL Server 2005. In this post, I'll take a look at the other ranking functions - RANK, DENSE_RANK, and NTILE. Let's begin with RANK and DENSE_RANK. These functions...
Craig Freedman's SQL Server Blog
Ranking Functions: ROW_NUMBER
Posted
Wed, Mar 19 2008
by
craigfr
1
Comments
SQL Server 2005 introduced four new functions, ROW_NUMBER, RANK, DENSE_RANK, and NTILE that are collectively referred to as ranking functions. These functions differ from ordinary scalar functions in that the result that they produce for a given row depends...
Craig Freedman's SQL Server Blog
Halloween Protection
Posted
Wed, Feb 27 2008
by
craigfr
2
Comments
In a prior post , I introduced the notion that update plans consist of two parts: a read cursor that identifies the rows to be updated and a write cursor that actually performs the updates. Logically speaking, SQL Server must execute the read cursor and...
Craig Freedman's SQL Server Blog
Maintaining Unique Indexes with IGNORE_DUP_KEY
Posted
Wed, Jan 30 2008
by
craigfr
3
Comments
A few months ago, I wrote a post describing how SQL Server maintains unique indexes while avoiding false uniqueness violations. In this post, I'm going to look at how SQL Server maintains unique indexes that were created with the WITH IGNORE_DUP_KEY clause...
Craig Freedman's SQL Server Blog
Partial Aggregation
Posted
Fri, Jan 18 2008
by
craigfr
1
Comments
In some of my past posts, I've discussed how SQL Server implements aggregation including the stream aggregate and hash aggregate operators. I also used hash aggregation as an initial example in my introductory post on parallel query execution . In this...
Craig Freedman's SQL Server Blog
Recursive CTEs continued ...
Posted
Wed, Nov 7 2007
by
craigfr
2
Comments
In this post, I will finish the discussion of recursive CTEs that I began in my last post. I will continue to use the CTE examples from Books Online . To run these examples, you'll need to install the Adventure Works Cycles OLTP sample database . In my...
Craig Freedman's SQL Server Blog
Recursive CTEs
Posted
Thu, Oct 25 2007
by
craigfr
1
Comments
One of the most important uses of CTEs is to write recursive queries. In fact, CTEs provide the only means to write recursive queries. As I noted last week , there are several excellent CTE examples, including recursive CTE examples, in Books Online ...
Page 1 of 3 (74 items)
1
2
3