[dba-SQLServer] indexes on cursors

Arthur Fuller fuller.artful at gmail.com
Mon Nov 12 22:16:54 CST 2007


There is a SQL clause called HINT which may or may not be useful in your
situation. It overrides the optimizer and tells it to forget looking at
other alternatives and instead use your hint, which is a directive to use
some particular index that the optimizer may have overlooked and/or not
deemed useful. Look up HINT in BOL for more detailed info.

hth,
A.

On 11/12/07, jwcolby <jwcolby at colbyconsulting.com> wrote:
>
> I built a crosstab as follows:
>
> SELECT St as USState, [C] as 'Canoe', [D] as 'Deck', [E] as 'Cat', [H] as
> 'House', [I] as 'Inflate', [J] as 'JetSki', [M] as 'Muscle', [P] as
> 'Pontoon',[T] as 'Waterski', [W] as 'Waterski2', [X] as 'Jet'
> FROM(
> SELECT     dbo.vAZHSIDFamilyHash.St, dbo.vBaseBoatType.Boat_Type
> FROM         dbo.vAZHSIDFamilyHash INNER JOIN dbo.vBaseBoatType
> ON dbo.vAZHSIDFamilyHash.PK = dbo.vBaseBoatType.PKID) BoatType
> PIVOT
> (
> COUNT(BoatType.Boat_Type)
> FOR BoatType.Boat_Type IN([C],[D],[E],[H],[I],[J],[M],[P],[T],[W],[X]))
> AS BT
> ORDER BY USState
>
> Notice the inner select tab is defined as a named cursor BoatType.  The
> fields making up the cursor, ST and Boat_Type both have indexes on them.
> Will the indexes be used for the outer select in order to perform the
> actual
> count and orderby?
>
> John W. Colby
> Colby Consulting
> www.ColbyConsulting.com
>
> _______________________________________________
> dba-SQLServer mailing list
> dba-SQLServer at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
> http://www.databaseadvisors.com
>
>



More information about the dba-SQLServer mailing list