Postgres does not use an index with "ORDER BY"

  • I have a very large table.
  • I have an index in col1 columns.
  • I would like to get data sorted by col1.
  • From the query plan, I can say that it does not use an index.
  • When I add "LIMIT", it starts using the index
  • For a large value for "LIMIT" it stops using the index.

Any clue?

PS I would like to get data grouped by col1 values ​​(not necessarily sorted), any sentences other than "ORDER BY".

THANK!!

+5
source share
2 answers

, , . , -, ?

set enable_seqscan = false

, , , .

ORDER BY - . , , -

Edit
: . , seq , . , , , seq, OP, .

+5

a_horse_with_no_name:

: , , . , . .

, . , , , . , (, , , ..) , ).

+4

All Articles