I have a table in SQL Server having 500+ million rows with default clustered index defined on the primary key of table. I am running this simple query which takes more than 30 minutes.
Select count(ledgeridXXX) from Ledger.dbo.tblXXXX
Here is the chunk of clustered index definition
CONSTRAINT [PK__tblDepar__AE70E0AFF9BAF7B9] PRIMARY KEY CLUSTERED
(
[LedgerIDXXX] ASC
)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON,
ALLOW_PAGE_LOCKS = ON
) ON [PRIMARY]
I don't have any clue where it could be wrong and why is it taking so much time. Please suggest me some ways or techniques on how to fix it as this is a critical table and main reporting heavily relies on this table.