Re: 8.3.1 query plan - Mailing list pgsql-general

From Tom Lane
Subject Re: 8.3.1 query plan
Date
Msg-id 958.1219900379@sss.pgh.pa.us
Whole thread Raw
In response to 8.3.1 query plan  (Steve Clark <sclark@netwolves.com>)
Responses Re: 8.3.1 query plan  (Steve Clark <sclark@netwolves.com>)
List pgsql-general
Steve Clark <sclark@netwolves.com> writes:
> explain insert into myevents select * from t_unit_event_log a where exists
>         (select b.event_log_no from myevents b
>          where a.event_status = 1 and a.event_ref_log_no IS NOT NULL
>                 and a.event_ref_log_no = b.event_log_no and a.event_log_no not in
>                         (select event_log_no from myevents)
>         )

Consider testing the conditions on A at the top level, instead of
redundantly checking them inside the sub-query on B.  I'm not certain
exactly how much that's hurting you (EXPLAIN ANALYZE output would've
been more informative), but it can't be good.

            regards, tom lane

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: strange explain analyze output
Next
From: "Matthew Dennis"
Date:
Subject: indexes on functions and create or replace function