SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Proper index for indexed view


Proper index for indexed view

Author
Message
pbaldy
pbaldy
SSC Journeyman
SSC Journeyman (98 reputation)SSC Journeyman (98 reputation)SSC Journeyman (98 reputation)SSC Journeyman (98 reputation)SSC Journeyman (98 reputation)SSC Journeyman (98 reputation)SSC Journeyman (98 reputation)SSC Journeyman (98 reputation)

Group: General Forum Members
Points: 98 Visits: 71
I have a view that is basically a UNION query on Great Plains data. The data I need to pull can be stored in any of 4 different header tables (each with an associated detail table), hence the view to pull them together. When I pull data from the view, the WHERE clause looks like:

WHERE AR.Line1Date Between @FmDate And @ToDate AND
AR.Company = @CoCode AND
AR.CustomerAccount BETWEEN @FmCust AND @ToCust

I'm not normally the one to do this type of thing, so I'm unclear whether 3 indexes on the 3 fields or a single index on the combination (is that a clustered index?) would be best. Any pointers would be appreciated.

TIA,

Paul



BI_Baracus
BI_Baracus
SSC Veteran
SSC Veteran (205 reputation)SSC Veteran (205 reputation)SSC Veteran (205 reputation)SSC Veteran (205 reputation)SSC Veteran (205 reputation)SSC Veteran (205 reputation)SSC Veteran (205 reputation)SSC Veteran (205 reputation)

Group: General Forum Members
Points: 205 Visits: 201
Hi Pbaldy,

unfortunately there are quite hefty restrictions on what can't be included in an indexed view an a union is one of them, please see the books online article below for the full list of restrictions.

http://msdn.microsoft.com/en-us/library/ms191432.aspx

just as an extra pointer using all 3 columns would be creating a composite index a clustered index is an entirely different creature, although you could use all 3 columns in a clustered index and you need a clustered index on an indexed view before you can add non clustered index's.

I have included an article on clustered and non clustered index's below that you might find interesting.

http://technet.microsoft.com/en-us/library/ms190457.aspx


Hope this was helpful.

J
pbaldy
pbaldy
SSC Journeyman
SSC Journeyman (98 reputation)SSC Journeyman (98 reputation)SSC Journeyman (98 reputation)SSC Journeyman (98 reputation)SSC Journeyman (98 reputation)SSC Journeyman (98 reputation)SSC Journeyman (98 reputation)SSC Journeyman (98 reputation)

Group: General Forum Members
Points: 98 Visits: 71
I appreciate the response and the info. I don't like the info, but I appreciate it. :-P



BI_Baracus
BI_Baracus
SSC Veteran
SSC Veteran (205 reputation)SSC Veteran (205 reputation)SSC Veteran (205 reputation)SSC Veteran (205 reputation)SSC Veteran (205 reputation)SSC Veteran (205 reputation)SSC Veteran (205 reputation)SSC Veteran (205 reputation)

Group: General Forum Members
Points: 205 Visits: 201
Tell me about it. I'd love to use them more but they're so prohibitive
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search