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

Started by PG Bug reporting formalmost 2 years ago2 messagesbugs
Jump to latest
#1PG Bug reporting form
noreply@postgresql.org

The following bug has been logged on the website:

Bug reference: 18552
Logged by: Li Yunfeng
Email address: yunfeng.li.nb@gmail.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))

#2David Rowley
dgrowleyml@gmail.com
In reply to: PG Bug reporting form (#1)
Re: BUG #18552: slow query, but using union is ok.

On Fri, 26 Jul 2024 at 00:01, PG Bug reporting form
<noreply@postgresql.org> wrote:

slow, waiting for a long time not return:

This is the wrong place to discuss slow queries. This mailing list is
for bug reports. Please read [1]https://wiki.postgresql.org/wiki/Slow_Query_Questions for instructions on how to get help
with your slow query.

David

[1]: https://wiki.postgresql.org/wiki/Slow_Query_Questions