小编Ale*_*kii的帖子

PostgreSQL 9.3 分页:计算页数

我执行分页和,让我们说,行的排序products表,使用上多列索引categoryscoreid

-- index
create index category_score_id on products(category, score, id)
  where active = true;

-- selecting first page
select * from products where
  category = 1
  and active = true
order by score desc, id desc
limit 30;

-- selecting following pages
select * from products where
  category = 1
  and active = true
  and (score, id) < (893, 102458)  -- values from previous page
order by score desc, id desc
limit …
Run Code Online (Sandbox Code Playgroud)

postgresql index postgresql-9.3

6
推荐指数
1
解决办法
6436
查看次数

标签 统计

index ×1

postgresql ×1

postgresql-9.3 ×1