Hey All,
I am not a PG expert. I like PG but i am puzzled as to what I shoud do .
I have a 4 core 5 GIG vm running a 500M db (it should fit to ram easly) and I face slow queries.
here is a view that I have :
SELECT o.id,
cc.name AS "from",
o.phone,
c.name AS "to",
parcel_info.value::character varying(64) AS email,
o.barcode AS barcode_global,
o.barcode_alt AS barcode,
uu.name AS destination,
cur.name AS source,
o.code,
tr.context AS status,
tr.gener AS last_update,
rc.value::character varying(254) AS refcode,
o.type,
slot_inf.title AS size
FROM data.orders o
LEFT JOIN data.clients c ON c.id = o.client_id
LEFT JOIN data.users u ON u.id = o.user_id
LEFT JOIN data.clients cc ON cc.id = u.client_id
LEFT JOIN data.users uu ON o.destin = uu.id
LEFT JOIN ( SELECT DISTINCT ON (ccsend.order_id) ccsend.order_id,
FROM data.ccsend
LEFT JOIN ( SELECT DISTINCT ON (track.order_id) track.order_id,
co.context,
track.gener
FROM data.track
LEFT JOIN data.contexts co ON co.id = track.context
LEFT JOIN ( SELECT oi.order_id,
oi.key,
oi.value
FROM data.orders_info oi
WHERE oi.key::text = 'email'::text) parcel_info ON parcel_info.order_id = o.id
LEFT JOIN ( SELECT orders_info.order_id,
orders_info.value
FROM data.orders_info
WHERE orders_info.key::text = 'refcode'::text) rc ON rc.order_id = o.id
LEFT JOIN data.slot_inf ON o.size = slot_inf.id;
and the xplain :https://explain.depesz.com/s/0LTn
It runs for ~5 seconds .
Can anyone suggest me anything on this ?
tx,
Gabliver