I have a database with millions of rows and I want to create an index which fixes performance issues as the query is over-using the processors. The database is hosted on MS Azure.
if I have a query similar to the following, for example to get employees who are not manager:
SELECT name, position, job title WHERE name LIKE '{0}%' AND manager = 0 AND employee = 1 ORDER BY senior DESC OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY
manager, employee and senior are all booleans (senior employees should show first in results)
We have tried something similar to the following but the server is still unable to handle the traffic:
CREATE NONCLUSTERED INDEX [IX_Index] ON [dbo].[Employees]
(
[Manager] ASC,
[Employee] ASC,
[Name] ASC
)
INCLUDE ( [Position],
[JobTitle],
[Senior]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = ON, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
The execution plan shows:
47% on index seek and 53% on top N sort if I search from SSMS
17% index seek, 26% parallelism, 56% sort on tracked queries from webapp
(both webapp and database are hosted on Azure)
What would be a proper index?
Edit:
I have received a suggestion to use a filtered index (like where manager = 0 and employee = 1)
but the sql server won't select it and I'm not able to force it. Any suggestions?