Re: View vs. Statement Query Plan

From: Gregory Seidman <gss+pg(at)cs(dot)brown(dot)edu>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: View vs. Statement Query Plan
Date: 2002-06-05 14:49:46
Message-ID: 20020605144946.GA19448@jamaica.cs.brown.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Martijn van Oosterhout sez:
[...]
} Nifty example:
}
} select lower(f) from (select f from a union select f from b);
} (select lower(f) from a) union (select lower(f) from b);
}
} If table a has "HELLO" and table b has "hello", the first will produce two
} rows of output, whereas the second produce only one. To work, you require
} the function to be *invertable* (1-to-1 mapping) which is pretty strict. Off
} the top of my head I'd say the vast majority would fail that test.
}
} UNION ALL would be fine I think, as long as the functions ware cachable and
} there were no aggregates. Basically, as long all you're pushing down is a
} cacheable projection.

As long as you aren't messing with the columns (no projections, no value
modifications, no aggregation), it is $\sigma_p(A) \cup \sigma_p(B)$ vs.
$\sigma_p(A \cup B)$. These are equivalent, regardless of whether it is a
proper UNION or a UNION ALL.

} Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
--Greg

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Oleg Bartunov 2002-06-05 14:53:29 Re: Insight into indexes? (or inverting then externally)
Previous Message Vince Vielhaber 2002-06-05 14:45:35 Re: How do I get a Digest subscription?