据我所知,覆盖索引是应该包含 SELECT 语句中所有列的索引。如果是这样,如果我有如下查询怎么办:
SELECT ActionDate -- Дата мероприятия
,ManagerName -- ФИО менеджера
,City -- Город мероприятия
,Organazer -- Юр.Лицо организатора
,[Action] -- Мероприятие
,Category -- Категория
,EnteringProfitability -- Входящая доходность %
,PlaceId
,PlaceName
-- Выручка
,SUM(isMetroCashDesk * Price) AS RevenueMetro --'Выручка:Кассы-метро'
,SUM(isRestCashDesk * Price) AS RevenueRest --'Выручка:Кассы-остальные'
,SUM(isPortal2CashDesk * Price) AS RevenuePortal2 --'Выручка:Портал 2.0'
,SUM(isEurosetCashDesk * Price) AS RevenueEuroset --'Выручка:Евросеть'
,SUM(isPartnersCashDesk * Price) AS RevenuePartners --'Выручка:Партнеры (субагенты)'
,SUM(isCashDesksPlatforms * Price) AS RevenueCashDesksPlatforms --'Выручка:Кассы-площадки'
-- Билеты
,SUM(isMetroCashDesk) AS TicketsMetro --'Билеты:Кассы-метро'
,SUM(isRestCashDesk) AS TicketsRest --'Билеты:Кассы-остальные'
,SUM(isPortal2CashDesk) AS TicketsPortal2 --'Билеты:Портал 2'
,SUM(isEurosetCashDesk) AS TicketsEuroset --'Билеты:Евросеть'
,SUM(isPartnersCashDesk) AS TicketsPartners --'Билеты:Партнеры (субагенты)'
,SUM(isCashDesksPlatforms) AS TicketsCashDesksPlatforms --'Билеты:Кассы-площадки'
-- Доход
,SUM(isMetroCashDesk * Income) AS IncomeMetro --'Доход:Кассы-метро'
,SUM(isRestCashDesk * Income) AS IncomeRest --'Доход:Кассы-остальные'
,SUM(isPortal2CashDesk * Income) AS IncomePortal2 --'Доход:Портал 2.0'
,SUM(isEurosetCashDesk * Income) AS IncomeEuroset --'Доход:Евросеть'
,SUM(isPartnersCashDesk * Income) AS IncomePartners --'Доход:Партнеры (субагенты)'
-- Итого
,SUM(Price) AS RevenueTotal --'Выручка:Итого, руб'
,COUNT(*) AS TicketsTotal --'Билеты:Итого, шт'
,SUM(Income) AS IncomeTotal --'Доход:Итого, руб'
,CASE SUM(Price) WHEN 0 THEN NULL ELSE 100.0 * SUM(Income)/SUM(Price) END AS Profitability --'Доходность:Итого,%'
-- Без касс-площадок и касс-устроителей
,SUM(CASE isCashDesksPlatforms WHEN 0 THEN Price ELSE 0 END) AS RevenueWithoutCashDesksPlatforms --Выручка
,SUM(CASE isCashDesksPlatforms WHEN 0 THEN 1 ELSE 0 END) AS TicketsWithoutCashDesksPlatforms --Билеты
,SUM(CASE isCashDesksPlatforms WHEN 0 THEN Income ELSE 0 END) AS IncomeWithoutCashDesksPlatforms --Доход
,CASE SUM(CASE isCashDesksPlatforms WHEN 0 THEN Price ELSE 0 END)
WHEN 0 THEN NULL
ELSE 100.0 * SUM(CASE isCashDesksPlatforms WHEN 0 THEN Income ELSE 0 END)/SUM(CASE isCashDesksPlatforms WHEN 0 THEN Price ELSE 0 END)
END AS ProfitabilityWithoutCashDesksPlatforms --Доходность
FROM #Goran
GROUP BY ActionDate
,ManagerName
,City
,Organazer
,[Action]
,Category
,EnteringProfitability
,PlaceId
,PlaceName
ORDER BY ActionDate
,ManagerName
,City
,Organazer
,[Action]
,Category
我认为我不能将 SELECT 部分中的所有列都包含在覆盖索引中。如果是这样,我怎样才能提高这个查询的性能?