pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Planner improvement suggestion
2+ messages / 2 participants
[nested] [flat]

* Planner improvement suggestion
@ 2005-08-28 20:59  Ilia Kantor <ilia@obnovlenie.ru>
  0 siblings, 1 reply; 2+ messages in thread

From: Ilia Kantor @ 2005-08-28 20:59 UTC (permalink / raw)
  To: pgsql-performance

I have a query:

 

SELECT oh.id
FROM objects_hier oh
where
oh.id < 2000 (!)
and
oh.id in (
      SELECT id as id FROM objects_access oa
      WHERE
      oa.master IN (1,2,10001)
      AND
      oa.id < 2000 (!)

)

 

The sense of the query is simple: I choose ids from objects_hier where
access has necessary masters.

 

The problem is: I have duplicate conditions for id here. They are marked
with '!'.

 

I just can't remove any of them, because planner needs to estimate both
outer and inner selects to calculate the order

Of nested loop or choose a join. If I remove one of duplicate conditions -
planner can't estimate well.

 

It's obvious that condition on oh.id can be put inside or outside "oh.id in
( .. )" statement with same result.

 

So I just suggest that the planner should take this into account and
"propagate" the condition outside or inside for planning if needed.

 

P.S

Is there a way to fix this particular query? Usually oh.id condition is not
like <2000, but an inner join.

 

 

 

 

 

 

^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Planner improvement suggestion
@ 2005-08-28 21:30  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Ilia Kantor <ilia@obnovlenie.ru>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2005-08-28 21:30 UTC (permalink / raw)
  To: Ilia Kantor <ilia@obnovlenie.ru>; +Cc: pgsql-performance

"Ilia Kantor" <ilia@obnovlenie.ru> writes:
> So I just suggest that the planner should take this into account and
> "propagate" the condition outside or inside for planning if needed.

I believe it does this already for equality conditions, but not for
inequalities.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2005-08-28 21:30 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-08-28 20:59 Planner improvement suggestion Ilia Kantor <ilia@obnovlenie.ru>
2005-08-28 21:30 ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox