I have table with index:
Table: Participates (player_id integer, other...) Indexes: "index_participates_on_player_id" btree (player_id) Table contains 400kk rows. I execute the same query two times:
Query: explain analyze select * from participates where player_id=149294217;
First time:
Index Scan using index_participates_on_player_id on participates (cost=0.57..19452.86 rows=6304 width=58) (actual time=261.061..2025.559 rows=332 loops=1) Index Cond: (player_id = 149294217) Total runtime: 2025.644 ms (3 rows) Second time:
Index Scan using index_participates_on_player_id on participates (cost=0.57..19452.86 rows=6304 width=58) (actual time=0.030..0.479 rows=332 loops=1) Index Cond: (player_id = 149294217) Total runtime: 0.527 ms (3 rows) So, first query has big actual time - how to increase speed the first execute?
UPDATE Sorry, How to accelerate first query?)
Why index scan search so slow?