Re: View Index and UNION

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Stefan Keller <sfkeller(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: View Index and UNION
Date: 2013-05-26 15:02:19
Message-ID: 12969.1369580539@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Stefan Keller <sfkeller(at)gmail(dot)com> writes:
> Given following schema:

> 1. TABLE a and TABLE b, each with INDEX on attribute geom.

> 2. A VIEW with union:

> CREATE VIEW myview AS
> SELECT * FROM a
> UNION
> SELECT * FROM b;

> 3. And a simple query with KNN index and a coordinate "mypos" :

> SELECT * FROM myview
> ORDER BY ST_Geomfromtext(mypos) <-> myview.geom

I think this would work out-of-the-box in 9.1 or later, if you
made the view use UNION ALL instead of UNION.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Josh Berkus 2013-05-26 15:18:10 Re: Planning incompatibilities for Postgres 10.0
Previous Message Hannu Krosing 2013-05-26 14:25:34 Re: Planning incompatibilities for Postgres 10.0