From: Erik Wienhold <ewie@ewie.name>
To: Marc Millas <marc.millas@mokadb.com>
To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: impact join syntax ?? and gist index ??
Date: Sat, 7 Jan 2023 21:40:09 +0100 (CET)
Message-ID: <832577793.126542.1673124009766@office.mailbox.org> (raw)
In-Reply-To: <CADX_1aabU_Og_tCEKX4MK=jkq1stgwFmxi0RsX5Qq8g1C1=LBg@mail.gmail.com>
References: <CADX_1aabU_Og_tCEKX4MK=jkq1stgwFmxi0RsX5Qq8g1C1=LBg@mail.gmail.com>
> On 07/01/2023 20:46 CET Marc Millas <marc.millas@mokadb.com> wrote:
>
> Hi,
>
> postgres 12, postgis 3.0
>
> I have a small table A, 11 rows with a varchar column x and a geometry column y.
> gist index on the geometry column.
> the geometry do contains multipolygons (regions on a map)
> I have a second table B , same structure, around 420 000 rows.
> no index,
> the geometry do contains points.
> all geometries are on 4326 srid.
>
> If i ask to count points in each multipolygons:
>
> select A.x, count(B.x) from A, B where st_within(B.y, A.y) group by A.x;
> it takes 11 seconds (everything in shared buffers).
> If I do the very same thing as:
> select A.x, count(B.x) from A left join B on st_within(B.y, A.y) group by A.x;
> same result, but 85 seconds (every thing in shared buffers, again)
> if I redo asking with explain analyze, buffers, the plan is very different.
>
>
> if I do create a gist index on geometry column of the big table, both syntax takes 21 seconds.
>
> I get the feeling I am missing something.. (at least 2 things...)
> can someone shed some light ??
Please provide the executions plans for both queries with and without the index on B.y.
--
Erik
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: ewie@ewie.name, marc.millas@mokadb.com
Subject: Re: impact join syntax ?? and gist index ??
In-Reply-To: <832577793.126542.1673124009766@office.mailbox.org>
References: <CADX_1aabU_Og_tCEKX4MK=jkq1stgwFmxi0RsX5Qq8g1C1=LBg@mail.gmail.com> <832577793.126542.1673124009766@office.mailbox.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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