Sample Header Ad - 728x90

Postgresql Query getting slow execution time

0 votes
1 answer
237 views
I did the explain analyze for this query, it was giving 30ms, but if the data is more I will get an execution expired; Using PostgreSQL 10 For normal execution: https://explain.depesz.com/s/gSPP For slow execution: https://explain.depesz.com/s/bQN2 SELECT inventory_histories.*, order_items.order_id as order_id FROM "inventory_histories" LEFT JOIN order_items ON (order_items.id = inventory_histories.reference_id AND inventory_histories.reference_type = 4) WHERE "inventory_histories"."inventory_id" = 1313 AND (inventory_histories.location_id = 15) ORDER BY inventory_histories.id DESC LIMIT 10 OFFSET 0; Indexes: "inventory_histories_pkey" PRIMARY KEY, btree (id) "inventory_histories_created_at_index" btree (created_at) "inventory_histories_inventory_id_index" btree (inventory_id) "inventory_histories_location_id_index" btree (location_id)
Asked by amtest (161 rep)
Nov 20, 2018, 08:13 AM
Last activity: May 24, 2021, 01:01 AM