Muhammad ADIL
Muhammad ADIL

Reputation: 303

Which query would be better for Paging?

Which query would be better for Paging Query 1 or Query 2

Query 1:

select CEILING(CONVERT(decimal,Count(*))/@PageSize) as TotalPages FROM  Table

Query 2:

Select (Count(*) + @PageSize - 1)/@PageSize as TotalPages FROM  Table

Upvotes: 3

Views: 59

Answers (1)

Jade
Jade

Reputation: 2992

Bases on your sample i'll go for the query 2

But technically speaking they both have the same performance in SQL Server, try executing them and see the execution plan.

Upvotes: 1

Related Questions