AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 23.09.2012, 00:11   #1  
Blog bot is offline
Blog bot
Участник
 
25,475 / 846 (79) +++++++
Регистрация: 28.10.2006
axStart: Cluster index
Источник: http://www.axstart.com/cluster-index...=cluster-index
==============

These days we have the surrogate key in AX 2012. In general it is a recid Index that acts as primary and cluster index. Theoretically this looks perfect as long as we develop in the AX 2012 style. But there is a catch to it. First you may think this index can’t get fragmented. This is true only when one AOS is running; when multiple AOSs are running, they all have their recid pool; so getting the latest record should not be “order by Recid DESC” but “order by createdDatetime” DESC.

What is the most common search query on the table? In case your code uses the recid in the find method, it is OK. Personally I can’t predict the most common search query on any table, especially when code is not live for a while and upgrade or conversion code is running.

So, how to solve this riddle; Well I found this blog post http://sqlserverplanet.com/indexes/c...lustered-index

It is a clever query

DECLARE @NonClusteredSeekPct float
DECLARE @ClusteredLookupFromNCPct float
SET @NonClusteredSeekPct = 1.50 — 150%
SET @ClusteredLookupFromNCPct = .75 — 75%

SELECT
    TableName                   = object_name(idx.object_id)
    ,NonUsefulClusteredIndex    = idx.NAME
    ,ShouldBeClustered          = nc.NonClusteredName
    ,Clustered_User_Seeks       = c.user_seeks
    ,NonClustered_User_Seeks    = nc.user_seeks
    ,Clustered_User_Lookups     = c.user_lookups
    ,DatabaseName               = db_name(c.database_id)
FROM sys.indexes idx
LEFT JOIN sys.dm_db_index_usage_stats c
ON idx.object_id = c.object_id
AND idx.index_id = c.index_id
JOIN (
    SELECT idx.object_id,nonclusteredname = idx.NAME,ius.user_seeks
    FROM sys.indexes idx
    JOIN sys.dm_db_index_usage_stats ius
    ON idx.object_id = ius.object_id AND idx.index_id = ius.index_id
    WHERE idx.type_desc = ‘nonclustered’ AND ius.user_seeks =
    (
        SELECT MAX(user_seeks) FROM sys.dm_db_index_usage_stats
        WHERE object_id = ius.object_id AND type_desc = ‘nonclustered’
    )
    GROUP BY idx.object_id,idx.NAME,ius.user_seeks
) nc
ON nc.object_id = idx.object_id
WHERE idx.type_desc IN (‘clustered’,'heap’)
AND nc.user_seeks > (c.user_seeks * @NonClusteredSeekPct)
AND nc.user_seeks >= (c.user_lookups * @ClusteredLookupFromNCPct)
ORDER BY TableName

 As you can see we still have a long way to go (it is default AX)





Источник: http://www.axstart.com/cluster-index...=cluster-index
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
axStart: Performance Guide Blog bot DAX Blogs 0 29.08.2012 14:11
axStart: Get in conrtol with Sharepoint DB names Blog bot DAX Blogs 0 29.08.2012 14:11
doens.be: Index vs Index hint Blog bot DAX Blogs 0 28.01.2011 23:14
Rajdip's space: The mystery of "index" vs. "index hint" Blog bot DAX Blogs 0 20.04.2010 20:05
axStart: Table caching in AX Blog bot DAX Blogs 3 31.08.2008 16:00

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 00:16.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.