BorderLayoutBoxedLayoutOpenLayoutMaximum textMedium textSmall text


Register
Thursday, March 11, 2010
 Â
MyStreamMinimize
Print  

Entries for the 'CTP6' Category

RE: Filtered indexes not compatible plan reuse

Posted by Jason Massie Click to IM Jason Massie on Friday, March 21, 2008 at 11:40 PM to SQL Server 2008, query optimizer, Indexes, CTP6, Procedure Cache
1742 Views | 1 Comments | Article Rating

Before the original post, I had submitted a connect item for something similar.

It turns out that filtered indexes may not be used when auto-parameterization(or for stored proc) occurs without a recompile hint. This is sort of understandable but I can think of workarounds and I suspect additional logic will be added in the future as mentioned below. Here is the feedback from a connect item I submitted.

"

Thanks for your feedback. The query in question, select lastname from Person.Contact where ContactID <=(100-20) is auto-parameterized by SQL Server into the following form, using the standard auto-parameterization rules: select lastname from Person.Contact where ContactID <=(@1-@2) These rules are designed to minimize compile time cost for simple queries like this, possibly at the expense of additional optimizations such as using a filtered index. Admittedly, it is a difficult tradeoff. In a future release, we'll consider extending the design to make a better decision in a cost-based way. For now, this behavior is by design.

"

alt head: You can't have your cake and eat it too.

email it! |   |   | 

SQL shorts

Posted by Jason Massie Click to IM Jason Massie on Friday, March 21, 2008 at 1:27 PM to SQL Server 2008, SQL Shorts, SQL Server 2005, Windows Server 2008, tsql, Indexes, Offtopic, Virtualization, CTP6
2401 Views | 1 Comments | Article Rating

We regret to inform you of a passing in the SQL community.   Read more here.

Rick Heiges has a post on my favorite new feature in SQL Server 2008, filtered indexes

So does Decipherinfosys along with a good description on the difference of indexes and statistics if you need some background.

SQLBlogcasts has gotten an upgrade and Tony posts some great stats. Congrats!

Not SQL per say but the Hyper-V release candidate has been released. Speaking of Hyper-V, Sriram posts his slide decks on virtualizing SQL. Part 1 and Part 2.

This is a great starting point for SQL Server 2008 as is this. These come by way of the MSDN\Technet update blog.

The SQL Server 2005 sp3 debate continues.

The SQL ISV team posts a performance improving cursor rewrite sample. However, it is not ANSI compliant :) which is odd since most ISV tsql code needs to be portable.

Paul Nielson will be releasing a DVD.

While we are at it, check out the new SQL Server social network.

alt head: Got ADD?

email it! |   |   | 

Filtered indexes not compatible plan reuse??

Posted by Click to IM Jason Massie on Sunday, March 16, 2008 at 5:31 AM to SQL Server 2008, query optimizer, Indexes, CTP6, Procedure Cache
2449 Views | 0 Comments | Article Rating

So I was messing around with filtered indexes tonight. Yes, beta software is my idea of a wild Saturday night. Hey, I played some Smash Bros first. ;) I was trying to figure out what happens if a plan is created using a covering but filtered index and try to reuse it with a parameter that is covered vertically but not horizontally. Let's look at this example: 

create database dbtest01;

--Force parameterization

alter database dbtest01 set parameterization forced;

 

use dbtest01

--create test table 1

create table t1

(id int identity(1,1),

c1 int,

c2 int)

 

--insert dummy data

declare @ctr int = 2000000

while @ctr > 0

begin

insert into t1(c1, c2) values (@ctr, @ctr)

select @ctr=@ctr-1

end

 

 

--create clustered indexes

create clustered index CI on t1(id)

 

 

--Let create a covering indexes that is pretty extreme.

create index ix01 on t1(c1) where c1 = 1990001

 

 

--Test queries

--ctrl + m

dbcc freeproccache

set statistics io on

 

--Does a CI scan.

select c1 from t1 

where c1 = 1990001

 

--Nope, index hints returns an error

--Query processor could not produce a query plan because of the hints defined in this query. Resubmit the query without specifying any hints and without using SET FORCEPLAN.

select c1 from t1  with (index=ix01)

where c1 = 1990001

 

--Ahh, recompile works. Now it uses the filtered index

select c1 from t1 

where c1 = 1990001

option(recompile)

 

 

--What about simple parameterization and a stored proc?

alter database dbtest01 set parameterization simple;

 

create proc proc1

@p1 int

as

select c1 from t1 

where c1 = @p1

 

--It does the CI scan

exec proc1 1990001

 

 

alter proc proc1

@p1 int

as

select c1 from t1 

where c1 = @p1

option(recompile)

 

--It uses the filtered index :)

exec proc1 1990001

email it! |   |   | 

SQL Server 2008 filtered indexes in 5 minutes

Posted by Jason Massie Click to IM Jason Massie on Saturday, February 23, 2008 at 11:11 PM to SQL Server 2008, SQL performance tuning, tsql, Indexes, CTP6, In 5 minutes
3687 Views | 1 Comments | Article Rating

My jaw literally dropped when I saw it. If this works as advertised, it has the potential of changing everything. The days of over indexing will be over. Dynamic indexing off of the missing and unused index DMV's could be possible especially with added support. I also think this will better accomplish what people tried to do with partitioning for performance reasons in SQL Server 2005.

It will be really interesting to see how it gets applied in production and where this leads in the next versions. Maybe an autoindex checkbox will replace the DBA :)

This is a small and quick example. We will have to see how it scales to larger environments.

 

use adventureworks

--Let's nullify a random 400

update  Production.WorkOrder

set EndDate = null

where WorkOrderID in (select top 400 WorkOrderID from Production.WorkOrder where enddate is not null)


--Let's give a random 200 a recent date to mimic prod data

update top (200) Production.WorkOrder

set duedate = getdate()-10

where enddate is null

--Base query
--This is query type that should be simple yet common
--Let's get open WO's that will be due soon

set statistics io on

select p.Name, wo.OrderQty, wo.DueDate

from Production.WorkOrder wo JOIN Production.Product p on wo.ProductID=p.ProductID

where wo.EndDate is null and wo.DueDate >= '2007-11-24'

 --CI Scan with loop join

--Table 'WorkOrder'. Scan count 1, logical reads 530, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
--Now let's create a covering index

create index ix01 on Production.WorkOrder(EndDate,DueDate, ProductID) include (OrderQty)

--Run the base query

set statistics io on
select
p.Name, wo.OrderQty, wo.DueDate
from
Production.WorkOrder wo JOIN Production.Product p on wo.ProductID=p.ProductID
where
wo.EndDate is null and wo.DueDate >= '2007-11-24'

--Does NCI seek

--Table 'WorkOrder'. Scan count 1, logical reads 5, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.

 

--Clean up

drop index [Production].[WorkOrder].[ix01]

 

--Create Filter index

create index ix01 on Production.WorkOrder(EndDate,DueDate, ProductID) include (OrderQty) where EndDate is null and DueDate >= '2007-11-24'

--Run base query

set statistics io on
select
p.Name, wo.OrderQty, wo.DueDate

from Production.WorkOrder wo JOIN Production.Product p on wo.ProductID=p.ProductID

where wo.EndDate is null and wo.DueDate >= '2007-11-24'

 

--It uses it. We have a real small sample but it performs better

--Table 'WorkOrder'. Scan count 1, logical reads 2, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
--Now let's look at size
--Create unfiltered index for comparison

create index ix02 on Production.WorkOrder(EndDate,DueDate, ProductID) include (OrderQty)

--note the new syntax

declare @dbid int = db_id()

declare @objid int = object_id('[Production].[WorkOrder]')

select * from sys.dm_db_index_physical_stats(@dbid, @objid, null, null, 'detailed') ps join sys.indexes i

on ps.object_id=i.object_id and ps.index_id=i.index_id

and i.name in ('ix01', 'ix02') and i.type_desc='NONCLUSTERED'

--We are looking at 2 page vs. 301 pages

That is a huge difference in size. The major point is not the fact that we retrieve the same while taking up so much less space on disk but so much less space in memory as well. We are going to get into this much more!

 

 Technorati Tags: ,,

email it! |   |   | 

SQL Shorts

Posted by Jason Massie Click to IM Jason Massie on Friday, February 22, 2008 at 2:53 PM to SQL Server 2008, SQL Server 2005, Windows Server 2008, CTP6
1108 Views | 0 Comments | Article Rating

The big news of the week is the release of CTP6. There millions of posts about it but let me point you to some interesting ones. Dennis Gobo points out the new DMV's. SSQA reports on the features that have been removed like SSNS. Personally, I think the highlight of the CTP is filtered indexes. I will be posting a blog about them this weekend.

Aaron points out that cumulative update 6 for SQL Server 2005 sp2 is available.

Uhoh, SQL Server driver for PHP CTP has been released. Get your LASP on. Haha. Joking aside. I went to a Windows 2008 event this week and MS is gunning for Apache. Hopefully, SQL powered PHP apps are better to support than SQL powered Java apps.

How nerdy are you? If you answered, very. Hop on over to the Second Life Technet event this Saturday. Details here.

Laurentiu Cristofor posts a FAQ on SQL Server password policies. He has some good info on his blog. Check it out.

Not new but relevant to DBA's, check out this Windows 2008 performance white paper.

email it! |   |   | 

SQL 2008 CTP6

Posted by Jason Massie Click to IM Jason Massie on Tuesday, February 19, 2008 at 7:17 PM to CTP6
716 Views | 0 Comments | Article Rating

http://download.microsoft.com/download/3/1/5/315b8683-3765-4426-96ec-179360abb82f/Download_Instructions_ENU.htm

or

http://www.microsoft.com/downloads/details.aspx?FamilyId=749BD760-F404-4D45-9AC0-D7F1B3ED1053&displaylang=en 

  • Powershell provider
  • Filtered indexes and stats!!!!!!!
  • Data and index compression
  • Lots of other stuff.

 

email it! |   |   | 

Microsoft SQL Server 2008 Feature Pack CTP, February 2008

Posted by Jason Massie Click to IM Jason Massie on Tuesday, February 19, 2008 at 4:42 PM to CTP6
600 Views | 0 Comments | Article Rating

CTP 6 must getting close. There have been various false alarms on blogs and BOL and the Feature pack is available.

 

email it! |   |   | 

Page 1 of 1First   Previous   Next   Last   


Copyright 2006 by Statistics IO, My SQL Server Blog