Добро пожаловать в форум, Guest  >>   Войти | Регистрация | Поиск | Правила | В избранное | Подписаться
Все форумы / Microsoft SQL Server Новый топик    Ответить
 Большое объединение join-ов  [new]
VitLF
Member

Откуда:
Сообщений: 339
Есть запрос выдранный через Reports - Top Queries by Average IO И Top Queries by Average CPU, который выполняется долго из-за нескольких объединений таблиц. Что можно сделать для оптимизации этого запроса?

select people . pId , ( case when people . out_date < '2011-10-26' then char ( 4 ) + 'icw95mbx01' when people . out_date < > '2099-01-01' and people . out_date > = '2011-10-26' then char ( 4 ) + 'icw95mbx03' else '' end ) , people . NUM_TAB , card . Full_Name , VPR_WK_TYPE . Work_Type , Appointments . Name_Appoint , PClass . Text_Prof , ( '(' + Structs . Name_internal + ') ' + Structs . Struct_Name ) , Structs_ROOT . Struct_Name , people . in_date , people . out_date , ( case when pr_current . code_temp > 0 then char ( 4 ) + 'rvv_p17_' when ISNULL ( temp_people . count_temp , 0 ) > 0 then char ( 4 ) + 'rvv_p16_' else '' end ) , ( case when pr_current . Code_temp > 0 then 'ВРЕМЕННОЕ ЗАМЕЩЕНИЕ ' when ISNULL ( temp_people . count_temp , 0 ) > 0 then 'ВРЕМЕННО ОТСУТСТВУЕТ (замещается) ' else ' ' end ) , ( case when isnull ( prik_ . id_group , 0 ) > 0 then 251 when isnull ( sov_ . id_group , 0 ) > 0 then 46 when VPR_WK_TYPE . Work_Status = 2 then 241 else ( case when VPR_WK_TYPE . Staff_With_Out = 0 then 247 else 239 end ) end ) , people . Auto_Card , people . Id_Firm , PR_CURRENT . Code_Struct_name , PR_CURRENT . prId , people . sovm , card . num_card , PR_CURRENT . ref_num , people . Ref_Num_Dep , PR_CURRENT . Act_Code , PR_CURRENT . Code_Appoint , CARD . Domain + ' ' + CARD . NetName , CARD . EMail , pr_orders . name + ( case when pr_orders . status_code = 5 then ' Подписан ' + convert ( varchar , pr_orders . date_sign , 104 ) when pr_orders . status_code = 1 then ' Подготовка' when pr_orders . status_code = 2 then ' На подписи' when pr_orders . status_code = 4 then ' Отменен ' else '' end ) , card . SocNumber , Structs . Struct_Root , Structs . Struct_Code , pr_current . cell_item , pr_current . Coeff_1 , pr_current . Coeff_2 , pr_current . Coeff_3 , pr_current . Coeff_4 , pr_current . Coeff_5 , VPR_WK_MOVCODE . Text_move , pr_current . number_w , pr_current . wage , prtb_source . name , ref_dep . name + ( case when ref_dep . status_code = 5 then ' Подписан ' + convert ( varchar , ref_dep . date_sign , 104 ) else ( case when ref_dep . status_code = 1 then ' Подготовка' else ( case when ref_dep . status_code = 2 then ' На подписи' else ( case when ref_dep . status_code = 4 then ' Отменен' else '' end ) end ) end ) end ) , mov_depart . Text_move , people . Visluga_prikaz , people . uname , people . mdate , people . Detail_Num_Dep , typ_regim . Name_Regim , typ_syspay . Name_syspay , VPR_WK_CATEG . Work_Categ_Name , ( case when sex = 0 then 'М' else 'Ж' end ) , pr_current . coeff_19 , z_cond_work . code , pr_current . poz , T . Text_Prof + ' (' + N . shortname + ')' , dbo . prfn_age ( CARD . date_birth , '2011-10-26' ) , Structs . name_internal , ( select App . Name_Appoint from cells ( NOLOCK ) join Appointments App ( NOLOCK ) on App . Code_Appoint = cells . Code_Appoint where PR_CURRENT . cell_item = cell_item ) , ( select PCl . Text_Prof from cells ( NOLOCK ) join PClass PCl ( NOLOCK ) on cells . Profi_Class = PCl . Code_Prof where PR_CURRENT . cell_item = cell_item ) from people ( NOLOCK ) inner join card on people . Auto_Card = card . Auto_Card inner join pr_current on pr_current . pid = people . pid and ( @0 between pr_current . date_trans and pr_current . date_depart ) inner join Appointments on Appointments . Code_Appoint = pr_current . Code_Appoint inner join Structs on PR_CURRENT . Code_Struct_Name = Structs . Struct_Code left join Structs Structs_ROOT on Structs_ROOT . Struct_code = Structs . Struct_root left join VPR_WK_CATEG on pr_current . work_categ = VPR_WK_CATEG . work_categ left join VPR_WK_TYPE on VPR_WK_TYPE . Work_Code = pr_current . Work_Code left join pr_orders on PR_CURRENT . ref_num = pr_orders . refer_num left join PClass on pr_current . W_Class = PClass . Code_Prof left join typ_regim on typ_regim . Code_Regim = pr_current . Code_Regim left join typ_syspay on typ_syspay . Code_syspay = pr_current . Code_syspay left join VPR_WK_MOVCODE on people . arrive = VPR_WK_MOVCODE . Code_move left join VPR_WK_MOVCODE mov_depart on people . depart = mov_depart . Code_Move left join prtb_source on prtb_source . id_source = people . from_organ left join pr_orders ref_dep on people . ref_num_dep = ref_dep . refer_num left join ( select prid , count ( * ) as count_temp from pr_temp_people where ( @1 between pr_temp_people . date_beg and pr_temp_people . date_end ) group by prid ) as temp_people on temp_people . prid = pr_current . prid left join z_cond_work ( NOLOCK ) on pr_current . cond_work = z_cond_work . id left join PClass_Tarif T ( NOLOCK ) on pr_current . tarif_id = T . CODE_PROF left join PClass_Tarif_name N ( NOLOCK ) on T . tarif_name_id = N . id left outer join pr_group_value sov_ ( NOLOCK ) on people . pid = sov_ . id_ref and id_group = @2 and @3 between sov_ . FromD and sov_ . ToD left outer join pr_group_value prik_ ( NOLOCK ) on people . pid = prik_ . id_ref and prik_ . id_group = @4 and @5 between prik_ . FromD and prik_ . ToD left outer join hrvw_typ_syspay_look ( NOLOCK ) on pr_current . code_syspay = hrvw_typ_syspay_look . id_typ_syspay where people . id_firm = @6 and exists ( select top 1 1 from tree tt ( NOLOCK ) where tt . struct_code = structs . struct_code and tt . struct_parent = @7 ) order by card . Full_Name option ( FAST 70 )
9 ноя 11, 14:58    [11570042]     Ответить | Цитировать Сообщить модератору
 Re: Большое объединение join-ов  [new]
SanyL
Member

Откуда: Москва
Сообщений: 4540
VitLF,

Вы хоть запрос от набора символов к виду запроса приведите... Пока такое прочитаешь - глаза сломаешь?
9 ноя 11, 15:08    [11570127]     Ответить | Цитировать Сообщить модератору
 Re: Большое объединение join-ов  [new]
VitLF
Member

Откуда:
Сообщений: 339
SanyL
VitLF,

Вы хоть запрос от набора символов к виду запроса приведите... Пока такое прочитаешь - глаза сломаешь?


Хорошо. Я вас понил, попробую...
9 ноя 11, 15:14    [11570191]     Ответить | Цитировать Сообщить модератору
 Re: Большое объединение join-ов  [new]
VitLF
Member

Откуда:
Сообщений: 339
SELECT 
    people.pId,
           (CASE 
            WHEN people.out_date < '2011-11-09' THEN char(4)+'icw95mbx01'  
             WHEN people.out_date <> '2099-01-01' AND people.out_date >=  '2011-11-09' THEN char(4)+'icw95mbx03'  
              ELSE '' 
         END),
         people.NUM_TAB, 
         card.Full_Name,
          VPR_WK_TYPE.Work_Type,
          Appointments.Name_Appoint,
          PClass.Text_Prof,
          ('('+Structs.Name_internal+') '+ Structs.Struct_Name), 
          Structs_ROOT.Struct_Name,
          people.in_date,
          people.out_date,
          (case 
             when pr_current.code_temp > 0                 then char(4) + 'rvv_p17_' 
            when ISNULL(temp_people.count_temp,0) > 0     then char(4) + 'rvv_p16_'
            else ''
             end),
         (CASE 
               WHEN pr_current.Code_temp > 0                  then 'ВРЕМЕННОЕ ЗАМЕЩЕНИЕ                 ' 
            WHEN ISNULL(temp_people.count_temp,0) > 0    then 'ВРЕМЕННО ОТСУТСТВУЕТ (замещается)   '
              else  '                                    ' 
         END),
          (CASE
            when isnull(prik_.id_group,0)>0 then 251 
            when isnull(sov_.id_group,0)>0 then 46 
            WHEN VPR_WK_TYPE.Work_Status = 2 then 241 else 
          ( CASE WHEN VPR_WK_TYPE.Staff_With_Out = 0 then 247 else 239 END ) END), 
          people.Auto_Card,
          people.Id_Firm, 
          PR_CURRENT.Code_Struct_name,
          PR_CURRENT.prId,
          people.sovm,
        card.num_card,
          PR_CURRENT.ref_num,
          people.Ref_Num_Dep,
          PR_CURRENT.Act_Code,
          PR_CURRENT.Code_Appoint,
        CARD.Domain + ' ' + CARD.NetName,
        CARD.EMail,
        pr_orders.name +
        (CASE WHEN pr_orders.status_code = 5 THEN ' Подписан  ' + convert(varchar, pr_orders.date_sign, 104)
              WHEN pr_orders.status_code = 1 THEN ' Подготовка'
              WHEN pr_orders.status_code = 2 THEN ' На подписи'
              WHEN pr_orders.status_code = 4 THEN ' Отменен   ' 
            ELSE ''
         END),
        card.SocNumber,
          Structs.Struct_Root,
          Structs.Struct_Code,

        pr_current.cell_item,
         pr_current.Coeff_1, pr_current.Coeff_2, pr_current.Coeff_3, pr_current.Coeff_4, pr_current.Coeff_5,
        VPR_WK_MOVCODE.Text_move,
        pr_current.number_w,
        pr_current.wage,
        prtb_source.name,
         ref_dep.name +
        (CASE WHEN ref_dep.status_code = 5 THEN ' Подписан ' + convert(varchar, ref_dep.date_sign, 104) ELSE 
        (CASE WHEN ref_dep.status_code = 1 THEN ' Подготовка' ELSE 
        (CASE WHEN ref_dep.status_code = 2 THEN ' На подписи' ELSE 
        (CASE WHEN ref_dep.status_code = 4 THEN ' Отменен' ELSE ''
         END)END)END)END),
        mov_depart.Text_move,
        people.Visluga_prikaz,
          people.uname, 
         people.mdate,
         people.Detail_Num_Dep,

    typ_regim.Name_Regim,
    typ_syspay.Name_syspay
         ,VPR_WK_CATEG.Work_Categ_Name "Категория"        
 --        ,(select top 1 Name_Regim from typ_Regim where typ_Regim.Code_Regim=pr_current.Code_Regim)[]"Тип режима" 
        ,(case when sex=0 then 'М' else 'Ж' end)
        ,pr_current.coeff_19
        ,z_cond_work.code 
        ,pr_current.poz 
        ,T.Text_Prof + ' (' + N.shortname + ')'
        ,dbo.prfn_age(CARD.date_birth, '2011-11-09') 
        ,Structs.name_internal 
        ,(Select App.Name_Appoint from cells (NOLOCK) 
               JOIN Appointments App (NOLOCK) ON App.Code_Appoint = cells.Code_Appoint where PR_CURRENT.cell_item = cell_item)
        ,(Select PCl.Text_Prof from cells (NOLOCK) 
              JOIN PClass PCl (NOLOCK) ON cells.Profi_Class = PCl.Code_Prof where PR_CURRENT.cell_item = cell_item)
  --     ,hrvw_typ_syspay_look.name 
--    ,isnull(ww.p,'нет')
FROM  people (NOLOCK)  
    INNER JOIN card  ON people.Auto_Card = card.Auto_Card
    INNER JOIN pr_current        ON pr_current.pid = people.pid 
        AND    ('2011-11-09' between pr_current.date_trans and pr_current.date_depart)

    INNER JOIN Appointments        ON Appointments.Code_Appoint = pr_current.Code_Appoint
    INNER JOIN Structs            ON PR_CURRENT.Code_Struct_Name = Structs.Struct_Code
    LEFT  JOIN Structs Structs_ROOT ON Structs_ROOT.Struct_code = Structs.Struct_root

        LEFT  JOIN VPR_WK_CATEG  ON pr_current.work_categ = VPR_WK_CATEG.work_categ
           LEFT  JOIN VPR_WK_TYPE   ON VPR_WK_TYPE.Work_Code = pr_current.Work_Code

           LEFT  JOIN pr_orders  ON PR_CURRENT.ref_num = pr_orders.refer_num
           LEFT  JOIN PClass  ON pr_current.W_Class = PClass.Code_Prof

        LEFT  JOIN typ_regim  ON typ_regim.Code_Regim = pr_current.Code_Regim
        LEFT  JOIN typ_syspay  ON typ_syspay.Code_syspay = pr_current.Code_syspay


    LEFT  JOIN VPR_WK_MOVCODE  ON people.arrive = VPR_WK_MOVCODE.Code_move
    LEFT  JOIN VPR_WK_MOVCODE mov_depart  ON people.depart = mov_depart.Code_Move
    LEFT  JOIN prtb_source  ON prtb_source.id_source = people.from_organ
    LEFT  JOIN pr_orders ref_dep  ON people.ref_num_dep = ref_dep.refer_num

    LEFT JOIN
    (    SELECT     prid, count(*) as count_temp
        FROM     pr_temp_people
        WHERE
            ('2011-11-09' between pr_temp_people.date_beg and pr_temp_people.date_end)
        GROUP BY prid
    ) as temp_people ON temp_people.prid = pr_current.prid
     left JOIN z_cond_work     (NOLOCK) ON  pr_current.cond_work = z_cond_work.id  
     left JOIN PClass_Tarif T    (NOLOCK) ON  pr_current.tarif_id = T.CODE_PROF  
     left JOIN PClass_Tarif_name N    (NOLOCK) ON  T.tarif_name_id = N.id  
   LEFT OUTER JOIN pr_group_value sov_ (NOLOCK) ON people.pid = sov_.id_ref and id_group=219 and '2011-11-09' between sov_.FromD and sov_.ToD
   LEFT OUTER JOIN pr_group_value prik_ (NOLOCK) ON people.pid = prik_.id_ref and prik_.id_group=233 and '2011-11-09' between prik_.FromD and prik_.ToD
   LEFT OUTER JOIN hrvw_typ_syspay_look (NOLOCK) ON pr_current.code_syspay = hrvw_typ_syspay_look.id_typ_syspay 
/*    left join (select top (1) WITH TIES
            cast('да' as varchar(3)) as p,pu.auto_card
        from prtb_union pu
        where '2011-11-09' between pu.d_from and pu.d_to
        order by ROW_NUMBER() over (partition by pu.auto_card order by pu.d_to desc) 
    )ww on ww.auto_card=card.auto_card*/
WHERE
    people.id_firm = 1


AND '2011-11-09' between people.in_date AND people.out_date

ORDER BY card.Full_Name


Сообщение было отредактировано: 9 ноя 11, 15:42
9 ноя 11, 15:27    [11570293]     Ответить | Цитировать Сообщить модератору
 Re: Большое объединение join-ов  [new]
VitLF
Member

Откуда:
Сообщений: 339
VitLF
SELECT
people.pId,
(CASE
WHEN people.out_date < '2011-11-09' THEN char(4)+'icw95mbx01'
WHEN people.out_date <> '2099-01-01' AND people.out_date >= '2011-11-09' THEN char(4)+'icw95mbx03'
ELSE ''
END),
people.NUM_TAB,
card.Full_Name,
VPR_WK_TYPE.Work_Type,
Appointments.Name_Appoint,
PClass.Text_Prof,
('('+Structs.Name_internal+') '+ Structs.Struct_Name),
Structs_ROOT.Struct_Name,
people.in_date,
people.out_date,
(case
when pr_current.code_temp > 0 then char(4) + 'rvv_p17_'
when ISNULL(temp_people.count_temp,0) > 0 then char(4) + 'rvv_p16_'
else ''
end),
(CASE
WHEN pr_current.Code_temp > 0 then 'ВРЕМЕННОЕ ЗАМЕЩЕНИЕ '
WHEN ISNULL(temp_people.count_temp,0) > 0 then 'ВРЕМЕННО ОТСУТСТВУЕТ (замещается) '
else ' '
END),
(CASE
when isnull(prik_.id_group,0)>0 then 251
when isnull(sov_.id_group,0)>0 then 46
WHEN VPR_WK_TYPE.Work_Status = 2 then 241 else
( CASE WHEN VPR_WK_TYPE.Staff_With_Out = 0 then 247 else 239 END ) END),
people.Auto_Card,
people.Id_Firm,
PR_CURRENT.Code_Struct_name,
PR_CURRENT.prId,
people.sovm,
card.num_card,
PR_CURRENT.ref_num,
people.Ref_Num_Dep,
PR_CURRENT.Act_Code,
PR_CURRENT.Code_Appoint,
CARD.Domain + ' ' + CARD.NetName,
CARD.EMail,
pr_orders.name +
(CASE WHEN pr_orders.status_code = 5 THEN ' Подписан ' + convert(varchar, pr_orders.date_sign, 104)
WHEN pr_orders.status_code = 1 THEN ' Подготовка'
WHEN pr_orders.status_code = 2 THEN ' На подписи'
WHEN pr_orders.status_code = 4 THEN ' Отменен '
ELSE ''
END),
card.SocNumber,
Structs.Struct_Root,
Structs.Struct_Code,

pr_current.cell_item,
pr_current.Coeff_1, pr_current.Coeff_2, pr_current.Coeff_3, pr_current.Coeff_4, pr_current.Coeff_5,
VPR_WK_MOVCODE.Text_move,
pr_current.number_w,
pr_current.wage,
prtb_source.name,
ref_dep.name +
(CASE WHEN ref_dep.status_code = 5 THEN ' Подписан ' + convert(varchar, ref_dep.date_sign, 104) ELSE
(CASE WHEN ref_dep.status_code = 1 THEN ' Подготовка' ELSE
(CASE WHEN ref_dep.status_code = 2 THEN ' На подписи' ELSE
(CASE WHEN ref_dep.status_code = 4 THEN ' Отменен' ELSE ''
END)END)END)END),
mov_depart.Text_move,
people.Visluga_prikaz,
people.uname,
people.mdate,
people.Detail_Num_Dep,

typ_regim.Name_Regim,
typ_syspay.Name_syspay
,VPR_WK_CATEG.Work_Categ_Name "Категория"
-- ,(select top 1 Name_Regim from typ_Regim where typ_Regim.Code_Regim=pr_current.Code_Regim)[]"Тип режима"
,(case when sex=0 then 'М' else 'Ж' end)
,pr_current.coeff_19
,z_cond_work.code
,pr_current.poz
,T.Text_Prof + ' (' + N.shortname + ')'
,dbo.prfn_age(CARD.date_birth, '2011-11-09')
,Structs.name_internal
,(Select App.Name_Appoint from cells (NOLOCK)
JOIN Appointments App (NOLOCK) ON App.Code_Appoint = cells.Code_Appoint where PR_CURRENT.cell_item = cell_item)
,(Select PCl.Text_Prof from cells (NOLOCK)
JOIN PClass PCl (NOLOCK) ON cells.Profi_Class = PCl.Code_Prof where PR_CURRENT.cell_item = cell_item)
-- ,hrvw_typ_syspay_look.name
-- ,isnull(ww.p,'нет')
FROM people (NOLOCK)
INNER JOIN card ON people.Auto_Card = card.Auto_Card
INNER JOIN pr_current ON pr_current.pid = people.pid
AND ('2011-11-09' between pr_current.date_trans and pr_current.date_depart)

INNER JOIN Appointments ON Appointments.Code_Appoint = pr_current.Code_Appoint
INNER JOIN Structs ON PR_CURRENT.Code_Struct_Name = Structs.Struct_Code
LEFT JOIN Structs Structs_ROOT ON Structs_ROOT.Struct_code = Structs.Struct_root

LEFT JOIN VPR_WK_CATEG ON pr_current.work_categ = VPR_WK_CATEG.work_categ
LEFT JOIN VPR_WK_TYPE ON VPR_WK_TYPE.Work_Code = pr_current.Work_Code

LEFT JOIN pr_orders ON PR_CURRENT.ref_num = pr_orders.refer_num
LEFT JOIN PClass ON pr_current.W_Class = PClass.Code_Prof

LEFT JOIN typ_regim ON typ_regim.Code_Regim = pr_current.Code_Regim
LEFT JOIN typ_syspay ON typ_syspay.Code_syspay = pr_current.Code_syspay


LEFT JOIN VPR_WK_MOVCODE ON people.arrive = VPR_WK_MOVCODE.Code_move
LEFT JOIN VPR_WK_MOVCODE mov_depart ON people.depart = mov_depart.Code_Move
LEFT JOIN prtb_source ON prtb_source.id_source = people.from_organ
LEFT JOIN pr_orders ref_dep ON people.ref_num_dep = ref_dep.refer_num

LEFT JOIN
( SELECT prid, count(*) as count_temp
FROM pr_temp_people
WHERE
('2011-11-09' between pr_temp_people.date_beg and pr_temp_people.date_end)
GROUP BY prid
) as temp_people ON temp_people.prid = pr_current.prid
left JOIN z_cond_work (NOLOCK) ON pr_current.cond_work = z_cond_work.id
left JOIN PClass_Tarif T (NOLOCK) ON pr_current.tarif_id = T.CODE_PROF
left JOIN PClass_Tarif_name N (NOLOCK) ON T.tarif_name_id = N.id
LEFT OUTER JOIN pr_group_value sov_ (NOLOCK) ON people.pid = sov_.id_ref and id_group=219 and '2011-11-09' between sov_.FromD and sov_.ToD
LEFT OUTER JOIN pr_group_value prik_ (NOLOCK) ON people.pid = prik_.id_ref and prik_.id_group=233 and '2011-11-09' between prik_.FromD and prik_.ToD
LEFT OUTER JOIN hrvw_typ_syspay_look (NOLOCK) ON pr_current.code_syspay = hrvw_typ_syspay_look.id_typ_syspay
/* left join (select top (1) WITH TIES
cast('да' as varchar(3)) as p,pu.auto_card
from prtb_union pu
where '2011-11-09' between pu.d_from and pu.d_to
order by ROW_NUMBER() over (partition by pu.auto_card order by pu.d_to desc)
)ww on ww.auto_card=card.auto_card*/
WHERE
people.id_firm = 1


AND '2011-11-09' between people.in_date AND people.out_date

ORDER BY card.Full_Name


Или так, возможно ли вместо join попытаться создать вьюху (вероятно несколько вьюх), и как они спасут положение в плане производительности?
9 ноя 11, 15:41    [11570377]     Ответить | Цитировать Сообщить модератору
 Re: Большое объединение join-ов  [new]
komrad
Member

Откуда:
Сообщений: 5736
VitLF
Или так, возможно ли вместо join попытаться создать вьюху (вероятно несколько вьюх), и как они спасут положение в плане производительности?


а теперь надо показать план этого запроса
9 ноя 11, 15:47    [11570407]     Ответить | Цитировать Сообщить модератору
 Re: Большое объединение join-ов  [new]
VitLF
Member

Откуда:
Сообщений: 339
komrad
VitLF
Или так, возможно ли вместо join попытаться создать вьюху (вероятно несколько вьюх), и как они спасут положение в плане производительности?


а теперь надо показать план этого запроса


К сообщению приложен файл (plan.zip - 30Kb) cкачать
9 ноя 11, 15:57    [11570503]     Ответить | Цитировать Сообщить модератору
 Re: Большое объединение join-ов  [new]
Glory
Member

Откуда:
Сообщений: 104751
VitLF
Или так, возможно ли вместо join попытаться создать вьюху (вероятно несколько вьюх), и как они спасут положение в плане производительности?

Если вы думаете, что сервер будет выполняит ваши представления последовательно, как выборки к физическим таблицам, то вы ошибаетесь
9 ноя 11, 15:59    [11570525]     Ответить | Цитировать Сообщить модератору
 Re: Большое объединение join-ов  [new]
VitLF
Member

Откуда:
Сообщений: 339
Glory
VitLF
Или так, возможно ли вместо join попытаться создать вьюху (вероятно несколько вьюх), и как они спасут положение в плане производительности?

Если вы думаете, что сервер будет выполняит ваши представления последовательно, как выборки к физическим таблицам, то вы ошибаетесь


Хорошо. Спасибо.
Я попытаюсь через утилиту DTA запрос прогнать.
9 ноя 11, 16:33    [11570855]     Ответить | Цитировать Сообщить модератору
 Re: Большое объединение join-ов  [new]
komrad
Member

Откуда:
Сообщений: 5736
VitLF,

попробуй добавить OPTION (LOOP JOIN) в конец запроса
9 ноя 11, 16:52    [11571032]     Ответить | Цитировать Сообщить модератору
Все форумы / Microsoft SQL Server Ответить