January 16, 2014 at 1:08 am
I was surprised to see that the question instructs people to run the query first. Should that not have been "without running the query, ..."? (That's how I did it - much more fun that way!)
Oh, I wanted people to get it right 100%.
π
January 16, 2014 at 1:17 am
Luis Cazares (1/15/2014)
One more reason for me to avoid index query hints, unless it's completely necessary and throughly tested.
The focus of the question is "How are filtered indexes usefull?".
My answer is "They are not so usefull as Indexed view".
If the filter is a little complex, the risk is that the optimizer does not use the index and starts a table scan (That's a problem on very populated table).
January 16, 2014 at 7:16 am
Very interesting one, Carlo. Thank you for the post. π
ww; Raghu
--
The first and the hardest SQL statement I have wrote- "select * from customers" - and I was happy and felt smart.
January 16, 2014 at 11:13 am
Carlo Romagnano (1/16/2014)
The focus of the question is "How are filtered indexes usefull?".My answer is "They are not so usefull as Indexed view".
Isn't this like saying that cars are more useful than scissors?
January 17, 2014 at 2:49 am
Excellent question New thing learned today, the 6th option is a tricky one
Every rule in a world of bits and bytes, can be bend or eventually be broken
MyBlog About Common dialog control
A Visualizer for viewing SqlCommand object script [/url]
January 17, 2014 at 5:04 am
Hugo Kornelis (1/16/2014)
Carlo Romagnano (1/16/2014)
The focus of the question is "How are filtered indexes usefull?".My answer is "They are not so usefull as Indexed view".
Isn't this like saying that cars are more useful than scissors?
I think more like comparing scissors to a guillotine. They both cut paper but one might chop your finger off if not used properly.
January 17, 2014 at 6:09 am
Sean Pearce (1/17/2014)
Hugo Kornelis (1/16/2014)
Carlo Romagnano (1/16/2014)
The focus of the question is "How are filtered indexes usefull?".My answer is "They are not so usefull as Indexed view".
Isn't this like saying that cars are more useful than scissors?
I think more like comparing scissors to a guillotine. They both cut paper but one might chop your finger off if not used properly.
+1
January 17, 2014 at 8:56 am
That was a nice one--though I have never encountered a case where I would intentionally use a filtered index on a table that also has an indexed view on it defined.
Generally I use filtered indexes as covering indexes--though I may be limiting optimization opportunities by doing so.
January 17, 2014 at 9:50 am
sneumersky (1/17/2014)
That was a nice one--though I have never encountered a case where I would intentionally use a filtered index on a table that also has an indexed view on it defined.Generally I use filtered indexes as covering indexes--though I may be limiting optimization opportunities by doing so.
I think that filtered index should be used simply with "flags/status".For example in a table with milions of records you can add a BIT column for identifying records to be processed.
create table t(id int, processed BIT NOT NULL DEFAULT 0)
create index idx_t on t(processed)
WHERE processed = 0
GO
--start processing
SELECT * FROM t
WHERE processed = 0
update t set processed = 1
where id = .......
-- end process
January 17, 2014 at 12:12 pm
Sean Pearce (1/17/2014)
Hugo Kornelis (1/16/2014)
Carlo Romagnano (1/16/2014)
The focus of the question is "How are filtered indexes usefull?".My answer is "They are not so usefull as Indexed view".
Isn't this like saying that cars are more useful than scissors?
I think more like comparing scissors to a guillotine. They both cut paper but one might chop your finger off if not used properly.
I have to disagree with that.
A view (whether indexed or not) exposes only a part of the data in the base table (assuming it's a view on a single table and without aggregation). Selecting from the view or selecting from the tables are dramatically different, they can produce completely different results.
An index (whether filtered or not) is a performance instrument. It should never influence the results returned by the query. That is the whole reason why some of these queries return an error - you are telling SQL Server to perform an impossible task.
The comparison made earlier in this topic is a comparison between queries that potentially return different result sets. In that case, depending on the question that was asked, at least one of the queries is simply incorrect. That has to be fixed first, It's not until you have two queries that will always return the same result set that you can start makiing comparisons between the two - focusing on performance, maintainability, or portability, depending on your needs.
Cheers,
Hugo
January 21, 2014 at 9:25 am
Good question.
Thanks
January 24, 2014 at 5:15 am
Absolutely stunning question on filtered indexes. Thanks Carlo. π
March 4, 2014 at 6:55 am
Excellent question, learned something new today. It's absolutely logcial, but I've never thougth about it.
π
/HΓ₯kan Winther
MCITP:Database Developer 2008
MCTS: SQL Server 2008, Implementation and Maintenance
MCSE: Data Platform
Viewing 13 posts - 16 through 27 (of 27 total)
You must be logged in to reply to this topic. Login to reply