Optimize query with OFFSET on large table
I have table create table big_table ( id serial primary key, -- other columns here vote int ); This table is very big, approximately 70 million rows, I need to query: SELECT * FROM big_table ORDER BY vote [ASC|DESC], id [ASC|DESC] OFFSET x LIMIT n -- I need this for pagination As you may know, when x is a large number, queries like this are very slow. For performance optimization I added indexes: create index vote_order_asc on big_table (vote asc, id asc); and create index vote_order_desc on big_table (vote desc, id desc); EXPLAIN shows that the above SELECT query uses these indexes, but it's