Home Forums SQL Server 2008 T-SQL (SS2K8) Indexed Views - why don't they improve performance?!!!! RE: Indexed Views - why don't they improve performance?!!!!

  • First, I assume you've all met all the oodles of restrictions for an indexed view; you might want to verify that using Books Online "CREATE INDEX", "Remarks", "Indexed Views" as a guied.

    Also, GROUP BY in the base query in exactly the same order as the clus index will be:

    create view dbo.withClusteredIdx

    with schemabinding

    as

    select c.Reference, mc.MPAN,ElementID,MONTH(hhdatetime) mm,YEAR(hhdatetime) yy

    ...

    group by YEAR(hhdatetime),MONTH(hhdatetime),c.Reference, mc.MPAN,ElementID

    CREATE UNIQUE CLUSTERED INDEX [idxTest] ON [dbo].[withClusteredIdx]

    (

    [yy] ASC,

    [mm] ASC,

    [Reference] ASC,

    [MPAN] ASC,

    [ElementID] ASC

    )

    go

    SELECT ...

    FROM dbo.withClusteredIdx

    WHERE

    yy >= @YEAR ... AND

    mm ...

    SQL DBA,SQL Server MVP(07, 08, 09) A socialist is someone who will give you the shirt off *someone else's* back.