Pavel
Stehule wrote: 2017-09-14 10:14 GMT+02:00 Frank Millman <frank@xxxxxxxxxxxx>:
please, send EXPLAIN ANALYZE result :)
I tried to reduce this to its simplest form.
Here is a SQL statement -
SELECT *
FROM ccc.ar_trans_due a
LEFT JOIN ccc.ar_trans b ON
b.tran_type = a.tran_type AND
b.tran_row_id = a.tran_row_id
WHERE a.row_id = 1
ar_trans_due is a physical table, ar_trans is a view.
It takes about 28ms. Here is the explain - https://explain.depesz.com/s/8YY
Then I changed it to join each of the physical tables, instead of the view
-
SELECT *
FROM ccc.ar_trans_due a
LEFT JOIN ccc.ar_tran_inv b ON
b.row_id = a.tran_row_id
LEFT JOIN ccc.ar_tran_crn c ON
c.row_id = a.tran_row_id
LEFT JOIN ccc.ar_tran_rec d ON
d.row_id = a.tran_row_id
WHERE a.row_id = 1
This takes just over 1ms. Here is the explain - https://explain.depesz.com/s/U29h
I tried setting enable_seq_scan to off – it ran even slower!
Frank
|