It was just a minimal example. The real query looks like this. select * from commons.financial_documents fd where fd.creation_time < '2011-11-07 10:39:07.285022+08' or (fd.creation_time = '2011-11-07 10:39:07.285022+08' and fd.financial_document_id < 100) order by fd.creation_time desc limit 200 I need to rewrite it in the way below to make Postgres use the index. select * from commons.financial_documents fd where fd.creation_time <= '2011-11-07 10:39:07.285022+08' and ( fd.creation_time < '2011-11-07 10:39:07.285022+08' or (fd.creation_time = '2011-11-07 10:39:07.285022+08' and fd.financial_document_id < 100) ) order by fd.creation_time desc limit 200 On 11/07/2014 12:38 PM, David Rowley
wrote:
|