A
A
Alexander Vladimirovich2019-11-14 13:30:15
PostgreSQL
Alexander Vladimirovich, 2019-11-14 13:30:15

What indexes were used in the query?

Greetings!
Where and how to see which indexes were used in postgresql when querying?
I did explain and explain analyze, but I can’t understand where there is about indexes

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
prostoprogrammist, 2019-11-14
@polyanin

If you don't see any indexes, then the scheduler has decided not to use the index. Here is the code from posgresql developer habr

postgres=# explain (costs off) select * from t where a = 1;
          QUERY PLAN          
-------------------------------
 Index Scan using t_a_idx on t
   Index Cond: (a = 1)
(2 rows)

где строчка " Index Scan using t_a_idx on t" означает использование индекса.

And proceeding from the explain'a laid out by you it is visible that the scheduler preferred Seq scan (consecutive scanning). And, in your request, the index is not needed at all. You don't even have a WHERE clause.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question