Re: Index View
From: Hugo Kornelis (hugo_at_pe_NO_rFact.in_SPAM_fo)
Date: 08/05/04
- Next message: rikesh: "Re: Alter Table"
- Previous message: Louis Davidson: "Re: Suppress ignore_dup_key error"
- In reply to: Prabhat: "Index View"
- Next in thread: Prabhat: "Re: Index View"
- Reply: Prabhat: "Re: Index View"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 05 Aug 2004 17:45:55 +0200
On Thu, 5 Aug 2004 19:52:02 +0530, Prabhat wrote:
>Hi All,
>
>I Have 2 Large TABLES and A View On which retrives records from Both the
>Tables Like:
>
>CREATE VIEW REAPPEALS_RECORDS
>AS
>SELECT
> A.Col1, A.Col2,
> B.Col1, B.Col2
> FROM Tabl1 A INNER JOIN Tabl2 B ON A.ID = B.ID
> WHERE B.Col5 = 'FLCC'
> AND B.Col6 < GETDATE()
> AND B.Col7 = 1
> AND (B.Col8 > 0 AND B.Col8 < 3)
> AND B.Col9 IN ('E', 'V')
>GO
>
>This takes around 15 - 20 sec. to retrive Data (Around 2000 rows.)
>How Can I Use / Convert this View to Index View so That I can Solve my
>performance problem.
>
>I am Using SQL Server 2000 Proff. Is Index View is Supported in This Ver? or
>Only I have to Use Ent. Ed to Use this feature. I also have Ent. Ed
>Installer in Different PC.
>
>Please Help.
>
>Thanks
>Prabhat
>
Hi Prabhat,
Indexed views are supported by SQL Server 2000. But I'm afraid that you
can't use this for your query. Views may only be indexed if they meet a
lot of requirements; one of these requirements is (quote from BOL):
--- All functions referenced by expressions in the view must be deterministic. The IsDeterministic property of the OBJECTPROPERTY function reports if a user-defined function is deterministic. For more information, see Deterministic and Nondeterministic Functions. --- Since GETDATE() is a deterministic function, the phrase "AND B.Col6 < GETDATE()" prohibits this view from being indexed. You could consider adding B.Col6 to the output of the view, removing the test on B.Col6 versus GETDATE() from the view definition and adding that when you select from the view. In that case, you can make this view indexed; check out the information in Books Online on indexed views for details (like using two-part naming etc.) But another thing you might consider is trying to enhance the performance of the existing query. How many rows are there in Tabl1 and Tabl2? What is the DDL of these tables? What indexes do you have defined? If you run SELECT * FROM REAPPEALS_RECORDS in QA with the option to show execution plan on (Ctrl-K), what indexes get used by SQL Server? Best, Hugo -- (Remove _NO_ and _SPAM_ to get my e-mail address)
- Next message: rikesh: "Re: Alter Table"
- Previous message: Louis Davidson: "Re: Suppress ignore_dup_key error"
- In reply to: Prabhat: "Index View"
- Next in thread: Prabhat: "Re: Index View"
- Reply: Prabhat: "Re: Index View"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|