We have Fact table around 35M rows on Azure database (premium tier), this table has cluster columnstore index enabled in order to boost query performance.
We did pagination (to index on Elastic Search) on Fact table using similar below code:
SELECT *
FROM [SPENDBY].[FactInvoiceDetail]
ORder by id
offset 1000000 rows fetch next 1000 rows only
But this query performs so slow, even over 10 minutes, it's not finished. If we change to use TOP
, it works really well and take around 30 seconds:
SELECT TOP 1000 *
FROM [SPENDBY].[FactInvoiceDetail]
WHERE ID > 1000000
ORDER BY Id
The estimated execution plan for offset-fetch query:
I am not sure that I understand whether offset-fetch
query performs very poorly on cluster columnstore index or not.
This table also have a lot of none-cluster B-tree indexes on foreign keys and one unique index on the Id
of Fact table in order to boost performance
This execution plan for offset-fetch query: