Duplicate Indexes
These indexes exist, but aren’t needed. Remove them
for faster writes.
rails generate migration remove_unneeded_indexes
And paste
remove_index :product_product, name: "product_product_product_tmpl_id_index", column: :product_tmpl_id
| Details |
On product_product
product_product_product_tmpl_id_index (product_tmpl_id)
is covered by
product_product_product_tmpl_id_default_code_idx (product_tmpl_id, default_code)
|
Suggested Indexes
Add indexes to speed up queries.
rails generate migration add_suggested_indexes
And paste
commit_db_transaction
add_index :swk_production_receipt, [:production_ticket], algorithm: :concurrently
Details
CREATE INDEX CONCURRENTLY ON swk_production_receipt (production_ticket)
Rows: 301172
Row progression: 301172, 1
Row estimates
- production_ticket (=): 1
- id (sort): 1
Existing indexes
- id PRIMARY
- name
to speed up
| Total Time |
Average Time |
Calls |
|
5 min
0.3%
|
103 ms
|
3,138
odoo
|
SELECT "swk_production_receipt".id FROM "swk_production_receipt" WHERE ("swk_production_receipt"."production_ticket" in ($1)) ORDER BY "swk_production_receipt"."id"
|
Slow Queries
Slow queries take 20 ms or more on average and have been called at least 100 times.
Explain queries to see where to add indexes.
| Total Time |
Average Time |
Calls |
|
635 min
41%
|
221 ms
|
171,965
odoo
|
SELECT "production_schedule_line".id FROM "production_schedule_line" WHERE ("production_schedule_line"."production_ticket_id" IS NULL AND ("production_schedule_line"."to_skip" IS NULL or "production_schedule_line"."to_skip" = false )) ORDER BY "production_schedule_line"."id"
|
|
9 min
0.6%
|
101 ms
|
5,607
odoo
|
SELECT min("stock_move".id) AS id, count("stock_move".id) AS "product_id_count" , sum("stock_move"."product_qty") AS "product_qty" ,"stock_move"."product_id" as "product_id"
FROM "stock_location" as "stock_move__location_id","stock_location" as "stock_move__location_dest_id","stock_move"
WHERE ("stock_move"."location_id"="stock_move__location_id"."id" AND "stock_move"."location_dest_id"="stock_move__location_dest_id"."id") AND ((((("stock_move"."state" not in ($1,$2,$3)) OR "stock_move"."state" IS NULL) AND ("stock_move"."product_id" in ($4))) AND (("stock_move__location_id"."parent_left" >= $5) AND ("stock_move__location_id"."parent_left" < $6))) AND (("stock_move__location_dest_id"."parent_left" < $7) OR ("stock_move__location_dest_id"."parent_left" >= $8)))
GROUP BY "stock_move"."product_id"
ORDER BY "id"
|
|
7 min
0.5%
|
743 ms
|
566
odoo
|
SELECT "material_requisition_line".id FROM "material_requisition_line" LEFT JOIN "res_partner" as "material_requisition_line__partner_id" ON ("material_requisition_line"."partner_id" = "material_requisition_line__partner_id"."id") LEFT JOIN "product_category" as "material_requisition_line__categ_id" ON ("material_requisition_line"."categ_id" = "material_requisition_line__categ_id"."id") LEFT JOIN "product_product" as "material_requisition_line__product_id" ON ("material_requisition_line"."product_id" = "material_requisition_line__product_id"."id") WHERE (("material_requisition_line"."schedule_id" = $1) AND ("material_requisition_line"."product_id" = $2)) ORDER BY "material_requisition_line__partner_id"."display_name" ,"material_requisition_line__categ_id"."parent_left" ,"material_requisition_line__product_id"."default_code" ,"material_requisition_line__product_id"."id"
|
|
5 min
0.3%
|
103 ms
|
3,138
odoo
|
SELECT "swk_production_receipt".id FROM "swk_production_receipt" WHERE ("swk_production_receipt"."production_ticket" in ($1)) ORDER BY "swk_production_receipt"."id"
Details
CREATE INDEX CONCURRENTLY ON swk_production_receipt (production_ticket)
Rows: 301172
Row progression: 301172, 1
Row estimates
- production_ticket (=): 1
- id (sort): 1
Existing indexes
- id PRIMARY
- name
|
|
4 min
0.2%
|
78 ms
|
2,832
odoo
|
SELECT min("stock_move".id) AS id, count("stock_move".id) AS "product_id_count" , sum("stock_move"."product_qty") AS "product_qty" ,"stock_move"."product_id" as "product_id"
FROM "stock_location" as "stock_move__location_id","stock_location" as "stock_move__location_dest_id","stock_move"
WHERE ("stock_move"."location_id"="stock_move__location_id"."id" AND "stock_move"."location_dest_id"="stock_move__location_dest_id"."id") AND ((((("stock_move"."state" not in ($1,$2,$3)) OR "stock_move"."state" IS NULL) AND ("stock_move"."product_id" in ($4))) AND ((("stock_move__location_id"."parent_left" >= $5) AND ("stock_move__location_id"."parent_left" < $6)) OR (("stock_move__location_id"."parent_left" >= $7) AND ("stock_move__location_id"."parent_left" < $8)))) AND ((("stock_move__location_dest_id"."parent_left" < $9) OR ("stock_move__location_dest_id"."parent_left" >= $10)) AND (("stock_move__location_dest_id"."parent_left" < $11) OR ("stock_move__location_dest_id"."parent_left" >= $12))))
GROUP BY "stock_move"."product_id"
ORDER BY "id"
|
|
3 min
0.2%
|
608 ms
|
255
odoo
|
SELECT "material_requisition_line".id FROM "material_requisition_line" LEFT JOIN "res_partner" as "material_requisition_line__partner_id" ON ("material_requisition_line"."partner_id" = "material_requisition_line__partner_id"."id") LEFT JOIN "product_category" as "material_requisition_line__categ_id" ON ("material_requisition_line"."categ_id" = "material_requisition_line__categ_id"."id") LEFT JOIN "product_product" as "material_requisition_line__product_id" ON ("material_requisition_line"."product_id" = "material_requisition_line__product_id"."id") WHERE ("material_requisition_line"."requisition_id" in ($1)) ORDER BY "material_requisition_line__partner_id"."display_name" ,"material_requisition_line__categ_id"."parent_left" ,"material_requisition_line__product_id"."default_code" ,"material_requisition_line__product_id"."id"
|
|
1 min
< 0.1%
|
131 ms
|
515
odoo
|
SELECT min("stock_move".id) AS id, count("stock_move".id) AS "product_id_count" , sum("stock_move"."product_qty") AS "product_qty" ,"stock_move"."product_id" as "product_id"
FROM "stock_location" as "stock_move__location_id","stock_location" as "stock_move__location_dest_id","stock_move"
WHERE ("stock_move"."location_dest_id"="stock_move__location_dest_id"."id" AND "stock_move"."location_id"="stock_move__location_id"."id") AND ((((("stock_move"."state" not in ($1,$2,$3)) OR "stock_move"."state" IS NULL) AND ("stock_move"."product_id" in ($4))) AND ((("stock_move__location_id"."parent_left" >= $5) AND ("stock_move__location_id"."parent_left" < $6)) OR (("stock_move__location_id"."parent_left" >= $7) AND ("stock_move__location_id"."parent_left" < $8)))) AND ((("stock_move__location_dest_id"."parent_left" < $9) OR ("stock_move__location_dest_id"."parent_left" >= $10)) AND (("stock_move__location_dest_id"."parent_left" < $11) OR ("stock_move__location_dest_id"."parent_left" >= $12)))) AND ("stock_move"."location_dest_id"="stock_move__location_dest_id"."id") AND (("stock_move"."company_id" IS NULL OR ("stock_move"."company_id" in ($13))) OR "stock_move__location_dest_id"."company_id" IS NULL )
GROUP BY "stock_move"."product_id"
ORDER BY "id"
|
|
1 min
< 0.1%
|
71 ms
|
515
odoo
|
SELECT min("stock_move".id) AS id, count("stock_move".id) AS "product_id_count" , sum("stock_move"."product_qty") AS "product_qty" ,"stock_move"."product_id" as "product_id"
FROM "stock_location" as "stock_move__location_dest_id","stock_location" as "stock_move__location_id","stock_move"
WHERE ("stock_move"."location_dest_id"="stock_move__location_dest_id"."id" AND "stock_move"."location_id"="stock_move__location_id"."id") AND ((((("stock_move"."state" not in ($1,$2,$3)) OR "stock_move"."state" IS NULL) AND ("stock_move"."product_id" in ($4))) AND ((("stock_move__location_dest_id"."parent_left" >= $5) AND ("stock_move__location_dest_id"."parent_left" < $6)) OR (("stock_move__location_dest_id"."parent_left" >= $7) AND ("stock_move__location_dest_id"."parent_left" < $8)))) AND ((("stock_move__location_id"."parent_left" < $9) OR ("stock_move__location_id"."parent_left" >= $10)) AND (("stock_move__location_id"."parent_left" < $11) OR ("stock_move__location_id"."parent_left" >= $12)))) AND ("stock_move"."location_dest_id"="stock_move__location_dest_id"."id") AND (("stock_move"."company_id" IS NULL OR ("stock_move"."company_id" in ($13))) OR "stock_move__location_dest_id"."company_id" IS NULL )
GROUP BY "stock_move"."product_id"
ORDER BY "id"
|