On Thu, Jun 6, 2024 at 1:25 PM Radu Radutiu <rradu...@gmail.com> wrote:

> Hello all,
>
> I have a query that forces an out of memory error, where the OS will kill
> the postgresql process.
> The query plan (run immediately after a vacuum analyze) is at
> https://explain.depesz.com/s/ITQI#html .
>
> ...

>
> Any idea on how to identify the problem? I can reproduce it on demand.
> Should I report it pgsql-bugs?
>
> Best regards,
> Radu
>

I am not qualified to answer on the OOM issue but why are you joining the
same table (outputrequest) 4 times (using an identical join condition)?
This essentially does a cross join, if an input_sequence value has say,
1000 related rows in outputrequest, you will be getting 1000^4 rows in the
result set.

  FROM inputrequest t
  LEFT JOIN outputrequest rec_tro
      ON rec_tro.input_sequence = t.input_sequence
  LEFT JOIN inputrequest r
      ON r.originalRequest_id = t.input_sequence
  LEFT JOIN outputrequest rpl_rec_tro
      ON rpl_rec_tro.input_sequence = r.input_sequence
  LEFT JOIN outputrequest rpl_snd_tro
      ON rpl_snd_tro.reply_input_sequence = r.input_sequence
  LEFT JOIN outputrequest snd_tro
      ON snd_tro.reply_input_sequence = t.input_sequence

Reply via email to