Skip to content

Commit

Permalink
Add desc indexes to optimize desc query
Browse files Browse the repository at this point in the history
  • Loading branch information
lenguyenthanh committed Apr 28, 2024
1 parent 55bf514 commit 52f1ba7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions docker-compose.gatling.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ services:
- 5432:5432
networks:
- fide_api
command: postgres -c shared_preload_libraries=pg_stat_statements -c pg_stat_statements.track=all
restart: unless-stopped
deploy:
resources:
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ services:
container_name: fide_postgres
volumes:
- ./.containers_data/postgres:/var/lib/postgresql/data
command: postgres -c shared_preload_libraries=pg_stat_statements -c pg_stat_statements.track=all
environment:
POSTGRES_DB: fide
POSTGRES_USER: admin
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
-- Add desc indexes for players
CREATE INDEX players_name_desc_idx ON players(name DESC NULLS LAST);
CREATE INDEX players_standard_desc_idx ON players(standard DESC NULLS LAST);
CREATE INDEX players_rapid_desc_idx ON players(rapid DESC NULLS LAST);
CREATE INDEX players_blitz_desc_idx ON players(blitz DESC NULLS LAST);

-- Add desc indexes for federations_summary
CREATE INDEX fed_sum_avg_rating_desc_idx ON federations_summary(avg_rating DESC NULLS LAST);
CREATE INDEX fed_sum_avg_standard_desc_idx ON federations_summary(avg_standard DESC NULLS LAST);
CREATE INDEX fed_sum_avg_rapid_desc_idx ON federations_summary(avg_rapid DESC NULLS LAST);
CREATE INDEX fed_sum_avg_blitz_desc_idx ON federations_summary(avg_blitz DESC NULLS LAST);
CREATE INDEX fed_sum_avg_top_standard_desc_idx ON federations_summary(avg_top_standard DESC NULLS LAST);
CREATE INDEX fed_sum_avg_top_rapid_desc_idx ON federations_summary(avg_top_rapid DESC NULLS LAST);
CREATE INDEX fed_sum_avg_top_blitz_desc_idx ON federations_summary(avg_top_blitz DESC NULLS LAST);
CREATE INDEX fed_sum_avg_top_standard_rank_desc_idx ON federations_summary(avg_top_standard_rank DESC NULLS LAST);
CREATE INDEX fed_sum_avg_top_rapid_rank_desc_idx ON federations_summary(avg_top_rapid_rank DESC NULLS LAST);
CREATE INDEX fed_sum_avg_top_blitz_rank_desc_idx ON federations_summary(avg_top_blitz_rank DESC NULLS LAST);
CREATE INDEX fed_sum_standard_players_desc_idx ON federations_summary(standard_players DESC NULLS LAST);
CREATE INDEX fed_sum_rapid_players_desc_idx ON federations_summary(rapid_players DESC NULLS LAST);
CREATE INDEX fed_sum_blitz_players_desc_idx ON federations_summary(blitz_players DESC NULLS LAST);
CREATE INDEX fed_sum_players_desc_idx ON federations_summary(players DESC NULLS LAST);

0 comments on commit 52f1ba7

Please sign in to comment.