public inbox for [email protected]  
help / color / mirror / Atom feed
From: Matheus de Oliveira <[email protected]>
To: joe meiring <[email protected]>
Cc: pgsql-performance <[email protected]>
Subject: Re: Odd behavior with indices
Date: Sun, 28 Feb 2016 10:26:11 -0300
Message-ID: <CAJghg4LjNjMX1Ppden+vhT-_=pPT2_gJZugc0F=8yzk1BUTtBw@mail.gmail.com> (raw)
In-Reply-To: <CAHd-1_4RUDmOLNOOJ6yKsZQEeHPKPHeAt7igOZLRiGK8WfF11Q@mail.gmail.com>
References: <CAHd-1_4RUDmOLNOOJ6yKsZQEeHPKPHeAt7igOZLRiGK8WfF11Q@mail.gmail.com>
List-Unsubscribe:  <mailto:[email protected]?body=unsub%20pgsql-performance>

Em 26 de fev de 2016 4:44 PM, "joe meiring" <[email protected]>
escreveu:
>
> The same query for parameters is rather slow and does NOT use the index:
>
> EXPLAIN ANALYZE
> select *
> from parameter
> where exists (
>       select 1 from datavalue
>       where datavalue.parameter_id = parameter.id limit 1
> );
>

Please, could you execute both queries without the LIMIT 1 and show us the
plans?

LIMIT in the inner query is like a fence and it caps some optimizations
available for EXISTS, you'd better avoid it and see if you get a proper
semi-join plan then.

Regards.


reply

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 using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: Odd behavior with indices
  In-Reply-To: <CAJghg4LjNjMX1Ppden+vhT-_=pPT2_gJZugc0F=8yzk1BUTtBw@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox