我执行分页和,让我们说,行的排序products表,使用上多列索引category,score和id。
-- 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)