PgHero
No long running queries
Connections healthy 8
Vacuuming healthy
No columns near integer overflow
No invalid indexes or constraints
9 duplicate indexes
Query stats must be enabled for slow queries

Duplicate Indexes

These indexes exist, but aren’t needed. Remove them for faster writes.

rails generate migration remove_unneeded_indexes

And paste

remove_index :categories, name: "idx_categories_slug", column: :slug
remove_index :product_images, name: "idx_product_images_product_id", column: :product_id
remove_index :products, name: "idx_products_brand_id", column: :brand_id
remove_index :products, name: "idx_products_category", column: :category_id
remove_index :products, name: "idx_products_category_id", column: :category_id
remove_index :products, name: "idx_products_cat_price_compound", column: [:category_id, :base_price]
remove_index :products, name: "idx_products_cat_price", column: [:category_id, :base_price]
remove_index :products, name: "idx_products_id", column: :id
remove_index :products, name: "idx_products_title_search", column: :"title gin_trgm_ops"
Details
On categories
idx_categories_slug (slug)
is covered by
categories_slug_key (slug)
On product_images
idx_product_images_product_id (product_id)
is covered by
idx_product_images_product (product_id)
On products
idx_products_brand_id (brand_id)
is covered by
idx_products_brand_price_compound (brand_id, base_price)
On products
idx_products_category (category_id)
is covered by
idx_cat_price (category_id, base_price)
On products
idx_products_category_id (category_id)
is covered by
idx_products_category (category_id)
On products
idx_products_cat_price_compound (category_id, base_price)
is covered by
idx_cat_price (category_id, base_price)
On products
idx_products_cat_price (category_id, base_price)
is covered by
idx_cat_price (category_id, base_price)
On products
idx_products_id (id)
is covered by
products_pkey (id)
On products
idx_products_title_search (title gin_trgm_ops)
is covered by
idx_products_search (title gin_trgm_ops, description gin_trgm_ops)

Query Stats

Make them available by adding the following lines to postgresql.conf:

shared_preload_libraries = 'pg_stat_statements'
pg_stat_statements.track = all

Restart the server for the changes to take effect.