Re: [HACKERS] Idea for speeding up uncorrelated subqueries

From: Vadim Mikheev <vadim(at)krs(dot)ru>
To: Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] Idea for speeding up uncorrelated subqueries
Date: 1999-08-06 04:01:57
Message-ID: 37AA5E35.66C03F2E@krs.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Bruce Momjian wrote:
>
> Isn't it something that takes only a few hours to implement. We can't
> keep telling people to us EXISTS, especially because most SQL people
> think correlated queries are slower that non-correlated ones. Can we
> just on-the-fly rewrite the query to use exists?

This seems easy to implement. We could look does subquery have
aggregates or not before calling union_planner() in
subselect.c:_make_subplan() and rewrite it (change
slink->subLinkType from IN to EXISTS and add quals).

Without caching implemented IN-->EXISTS rewriting always
has sence.

After implementation of caching we probably should call union_planner()
for both original/modified subqueries and compare costs/sizes
of EXISTS/IN_with_caching plans and maybe even make
decision what plan to use after parent query is planned
and we know for how many parent rows subplan will be executed.

Vadim

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 1999-08-06 04:14:50 Re: [HACKERS] Idea for speeding up uncorrelated subqueries
Previous Message Bruce Momjian 1999-08-06 03:31:01 Re: [HACKERS] Idea for speeding up uncorrelated subqueries