Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

Indexed View Expand / Collapse
Author
Message
Posted Tuesday, December 08, 2009 9:34 AM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Tuesday, April 03, 2012 8:35 AM
Points: 1,608, Visits: 198
Thanks, that is what I would have expected. CharIndex would create a situation that invalidates the Index View and basically forces SQL to the underlying tables.

But this does not in itself invalidate the question.


Raymond Laubert
Exceptional DBA of 2009 Finalist
MCT, MCDBA, MCITP:SQL 2005 Admin,
MCSE, OCP:10g
Post #830796
Posted Tuesday, December 08, 2009 4:06 PM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Wednesday, March 26, 2014 10:34 AM
Points: 2,278, Visits: 3,046
You have to add the noexpand hint to the query to use the view's index. The noexpand hint forces the optimizer to use the views data instead of the underlying tables and indexes. You have to remember that the optimizer is still cost efficient and sometimes it thinks the using the underlying data is cheaper than using the view data, which may be true in certain cases. Anyway you must use the noexpand hint to make the optimizer look at the view and its indexes only. On the flip side, you can use the expand hint to make the optimizer expand the view.



My blog: http://jahaines.blogspot.com
Post #831094
Posted Tuesday, December 08, 2009 9:04 PM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Friday, July 29, 2011 4:14 AM
Points: 318, Visits: 198
Thanks a lot Steve.
Post #831145
Posted Wednesday, December 09, 2009 1:46 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Thursday, April 03, 2014 3:33 PM
Points: 2,526, Visits: 530
Ray Laubert (12/8/2009)
Thanks, that is what I would have expected. CharIndex would create a situation that invalidates the Index View and basically forces SQL to the underlying tables.

But this does not in itself invalidate the question.


You are right it doesn't invalidate the question, but it is misleading information to everyone trying to create an indexed view with char index, and I think that is a bad.


/Håkan Winther
MCITP:Database Developer 2008
MCTS: SQL Server 2008, Implementation and Maintenance
Post #831212
Posted Thursday, December 10, 2009 7:50 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Saturday, September 29, 2012 6:38 AM
Points: 276, Visits: 21
What's about this question?

In SQL 2000 - CharIndex is nondeterministic
http://msdn.microsoft.com/en-us/library/aa214775(SQL.80).aspx

In SQL 2005 - CharIndex is deterministic
http://msdn.microsoft.com/en-us/library/ms178091(SQL.90).aspx

Sorry, but question didn't precise about which version sql server was going.

Please give me my lost point :)
Post #832235
Posted Tuesday, December 15, 2009 1:43 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Tuesday, November 05, 2013 6:08 AM
Points: 1,076, Visits: 591
Ray Laubert (12/8/2009)
Wasn't sure about CharIndex ...Has anyone ever used CharIndex on an indexed view?


But this was not because of the null reason...


What you don't know won't hurt you but what you know will make you plan to know better
Post #834338
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse