BUG #18552: slow query, but using union is ok.

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: yunfeng(dot)li(dot)nb(at)gmail(dot)com
Subject: BUG #18552: slow query, but using union is ok.
Date: 2024-07-25 09:53:58
Message-ID: 18552-c7180ffd32395469@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 18552
Logged by: Li Yunfeng
Email address: yunfeng(dot)li(dot)nb(at)gmail(dot)com
PostgreSQL version: 16.3
Operating system: CENTOS 7
Description:

slow, waiting for a long time not return:
select a.c_mrid,a.c_pathname from sjzx_breaker a
where (exists(select * from sjzx_disconnector b,sjzx_transformerwinding
c
where c.c_powertransformer='117093590563292490' and
(b.c_i_node=c.c_i_node or b.c_j_node=c.c_i_node)
and (b.c_i_node=a.c_i_node or b.c_i_node=a.c_j_node or
b.c_j_node=a.c_i_node or b.c_j_node=a.c_j_node)))
or exists(select * from sjzx_transformerwinding f
where f.c_powertransformer='117093590563292490' and
(f.c_i_node=a.c_i_node or f.c_i_node=a.c_j_node))

but using union, it is ok:
select a.c_mrid,a.c_pathname from sjzx_breaker a
where (exists(select * from sjzx_disconnector b,sjzx_transformerwinding
c
where c.c_powertransformer='117093590563292490' and
(b.c_i_node=c.c_i_node or b.c_j_node=c.c_i_node)
and (b.c_i_node=a.c_i_node or b.c_i_node=a.c_j_node or
b.c_j_node=a.c_i_node or b.c_j_node=a.c_j_node)))
union
select e.c_mrid,e.c_pathname from sjzx_breaker e where exists(select * from
sjzx_transformerwinding f
where f.c_powertransformer='117093590563292490' and
(f.c_i_node=e.c_i_node or f.c_i_node=e.c_j_node))

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message David Rowley 2024-07-25 12:06:01 Re: BUG #18552: slow query, but using union is ok.
Previous Message Thomas Munro 2024-07-25 06:08:49 Re: [EXTERNAL] Re: Windows Application Issues | PostgreSQL | REF # 48475607