sql server - Which query would be better for Paging? -


which query better paging query 1 or query 2

query 1:

select ceiling(convert(decimal,count(*))/@pagesize) totalpages  table 

query 2:

select (count(*) + @pagesize - 1)/@pagesize totalpages  table 

bases on sample i'll go query 2

but technically speaking both have same performance in sql server, try executing them , see execution plan.


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -