Force PostgreSQL to use an index, how?

0

Is there a way to force PostgreSQL to use a specific index?

I have two equal tables (different servers, of course), with the same indexes created in each one, however, on one server the index is used and the other is not.

I need to get the index, the SELECT is simple, it only has a JOIN but the table is too large, I need that index.

    
asked by anonymous 06.03.2018 / 20:36

1 answer

1

Perhaps nothing is wrong, the volume of data in those tables may be responsible for this behavior.

Think like this:

Imagine a book with 5000 pages. The best way to find something specific within this book would certainly be to use its index.

Now imagine a booklet of only% with% pages. The easiest way to find something in this booklet would be to flip it through, the need for an index is completely unnecessary and could even get in the way.

But if you want to venture to force 6 to work by giving preference to indexes, you can do something like:

SET enable_seqscan = OFF;
    
07.03.2018 / 14:29