Re: Proposed Query Planner TODO items

From: Greg Stark <gsstark(at)mit(dot)edu>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Proposed Query Planner TODO items
Date: 2003-12-05 20:41:26
Message-ID: 87y8tr0zgp.fsf@stark.dyndns.tv
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


I know Oracle is capable of producing the UNION plan. but I don't know if
that's the only option. I'm curious what indexes the rewritten union-based
query used.

Josh Berkus <josh(at)agliodbs(dot)com> writes:

> SELECT t1.a, t2.b
> FROM t1, t2
> WHERE t1.a = t2.a
> AND (
> ( t1.c = x
> AND t1.f IN (m, n, o)
> AND t2.d = v
> AND t2.e BETWEEN j AND k
> )
> OR
> ( t1.c = y
> AND t1.f IN (n, o, p)
> AND t2.d = v
> AND t2.e BETWEEN k AND h
> )
> OR
> ( t1.c = z
> AND t1.f IN (p, q)
> AND t2.d = w
> AND t2.e BETWEEN k AND h
> )
> )

In this case it seems like it might be possible to look for a covering set
that is guaranteed to include all the records and doesn't include any ORs. If
that covering set can be scanned quickly then the complex conditions could be
tested on the resulting records individually.

In this case it would be something like

select t1.a,t2.b from t1,t2 where t1.a = t2.a
and ( t1.c in (x,y,z)
and t1.f in (m,n,o,p,q)
and t2.d in (v,w)
and t2.e between min(j,k) and max(k,h)
)
and (.... the above constraints...)

It seems like it would be a lot of work and only help in narrow cases though.

--
greg

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Wildpaner 2003-12-05 22:28:01 Re: [BUG/PATCH] backend crashes during authentication if
Previous Message Josh Berkus 2003-12-05 20:14:37 Re: Proposed Query Planner TODO items