Michel Levy
|
|
Group: StrataFrame Users
Posts: 193,
Visits: 9K
|
Hi, All is OK when I create an index within SSMS with this script CREATE NONCLUSTERED INDEX [IX_ligne_1_rpt_et_dev1] ON [dbo].[ligne_1] ( [cde_cmd] ASC, [no_ligne_1] ASC, [cde_mat] ASC ) INCLUDE ( [epaisseur], [cal_surf], [surf_lq], [lq_m2], [px2_m2], [laq_l1], [laq_l2], [laq_f2], [modew], [mat_four], [libelle3], [longueur], [largeur], [raly], [com_lg1], [typ_laq], [fl_bcl]) WITH (SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF) ON [PRIMARY]but the same description in DDT raises an error when deployment (in log file
X 12/02/2010 16:19:50 -> Le index 'IX_ligne_1_rpt_et_dev1' sur la table 'dbo.ligne_1' a 20 noms de colonnes dans la liste de clés index. La limite maximale pour la liste des colonnes de clés d'index ou de statistiques est 16. Is that limit of 16 column names in an index definition a SF DDT limit, or a Microsoft SMO limit? We really need many indexes like this (with sometimes more than 40 columns as INCLUDE), and hoped that DDT could manage it. Thanks in advance
|
|
|
Trent Taylor
|
|
Group: StrataFrame Developers
Posts: 6.6K,
Visits: 6.9K
|
Wow, I have never created an index with that many columns! I would have to actually test this to give you any conclusive results. But most likely, this is a limit of SMO. There is an easy enough workaround for something like this. You could just use a Post Deployment Script to create this index if the standard T-SQL code is allowing it. I will have to look into the other.
|
|
|
Michel Levy
|
|
Group: StrataFrame Users
Posts: 193,
Visits: 9K
|
Trent, INCLUDing columns in index often improve performances, especially if you have complex views on tables with many columns (say more than 60 or 80 columns in 2 or more tables). You can see it in execution plans. I didn't think about post-deployment scripts as a workaround, but of course, it is probably the best way. Thanks for advice!
|
|
|
Trent Taylor
|
|
Group: StrataFrame Developers
Posts: 6.6K,
Visits: 6.9K
|
Yes, I live in execution plans and I also spend a vast amount of time creating the most optimized queries as possible. The other day we had a query that would have taken 60 minutes and by adding only a few keys, changing the logic, and using index hints, we got this same time down to 250 milliseconds. Regardless, that should give you a workaround.
|
|
|
Michel Levy
|
|
Group: StrataFrame Users
Posts: 193,
Visits: 9K
|
Trent, in DDT, I can't see where and how I can INCLUDE columns in index (not the columns that will be part of index expression, but those that will be included) Is it a SMO limit ? I mean, is the INCLUDE in index supported by SMO ?
|
|
|
Trent Taylor
|
|
Group: StrataFrame Developers
Posts: 6.6K,
Visits: 6.9K
|
Not sure that I know what you mean since I think this is a trick question. You can add the fields (columns) to an index when creating the index: Since I am sure that you already know this, then you may need to give me a little better understanding of what you are trying to accomplish.
|
|
|
Michel Levy
|
|
Group: StrataFrame Users
Posts: 193,
Visits: 9K
|
Trent, what you show here is similar to the following syntax: CREATE NONCLUSTERED INDEX [Your_index_name] ON [dbo].[GuidTest] ( [my_pk] ASC, [my_name] ASC )and what I want to do with DDT is similar to : CREATE NONCLUSTERED INDEX [Your_index_name] ON [dbo].[GuidTest] ( [my_pk] ASC, [my_name] ASC ) INCLUDE ( [my_other_field ASC, [and_another_one_here] ASC )
With the keyword include, the values of the "other fields" are store IN the index itself (really in the b-tree leaf corresponding to the record defined by the my_pk and my_name combination). Say we have a clustered index on the PK identity column, so the index is physically the table itself, and we need to retrieve a row that whe define by the 3 fields. In my real table, these fields are cde_cmd, no_ligne_1, and cde_mat). They define the combination I need in one of the JOIN of a view. But in the SELECT statement of that view, I'll ask for cal_surf, surf_lq, lq_m2, and so on. If these columns are in the INCLUDE statement of the index definition, their values will be brought up during the Non-Clustered index scan of the execution plan, and doing so, I shall avoid the cost of a Hash-Match table, using only a Merge Join. The more you need columns in the select statement, the more you need to look at the INCLUDE clause in your indexes definition. Does it make sense?
|
|
|
Trent Taylor
|
|
Group: StrataFrame Developers
Posts: 6.6K,
Visits: 6.9K
|
Michel, A couple of things. I have verified that the 16 columns (or 900 characters) for a covering index is the limit for SQL Server and has nothing to do with SMO per say. SMO just enforces these rules in a more strict manner. Here is a paragraph from SQL Server Performance about this specific issue: Covering indexes, if used judiciously, can be used to speed up many types of commonly run queries. But covering indexes have some limitations. For example, they are limited to a maximum of 16 columns; they have a 900-character maximum width; certain datatypes cannot be included in them; and adding additional columns to an index makes the index wider, which in turn requires more disk I/O to read and write the rows, potentially hurting performance, especially if the table is subject to many INSERTs, UPDATEs, and DELETEs. Here is a link that may give you more details and insight about this: http://www.sql-server-performance.com/articles/clustering/create_nonkey_columns_p1.aspx Next, as for the INCLUDED tag on the index, yes, you are correct that at present the DDT does not support this. We have added this to the list for a future update, but will not be immediately implemented.
|
|
|
Michel Levy
|
|
Group: StrataFrame Users
Posts: 193,
Visits: 9K
|
Trent, AFAIK (and what I read in BOL), 16 is the max # of key columns in the index definition, but INCLUDE may content 1 to 1023 columns... Yes, there's a risk to enlarge the index size, and to increase disk I/O. If the columns you would include are all Char(100), sure you'll see bad performances. But when I have 20 or even 40 columns of SmallInt, there is a huge benefice of using Include columns. And for DDT, I'll wait for the future update (before 2015, please, because I'll be retired )
|
|
|
Trent Taylor
|
|
Group: StrataFrame Developers
Posts: 6.6K,
Visits: 6.9K
|
I'm not trying to debate philosophy, and the 16 column limit is referring to the covering indexes, not the INCLUDE columns which are not currently supported anyway. But this is something that we will add to the DDT as we see the need. Thanks.
|
|
|