Re: Odd behavior with indices

From: Matheus de Oliveira <matioli(dot)matheus(at)gmail(dot)com>
To: joe meiring <josephmeiring(at)gmail(dot)com>
Cc: pgsql-performance <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Odd behavior with indices
Date: 2016-02-28 13:26:11
Message-ID: CAJghg4LjNjMX1Ppden+vhT-_=pPT2_gJZugc0F=8yzk1BUTtBw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Em 26 de fev de 2016 4:44 PM, "joe meiring" <josephmeiring(at)gmail(dot)com>
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.

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Tom Lane 2016-02-29 18:47:12 Re: Odd behavior with indices
Previous Message David Rowley 2016-02-28 10:06:35 Re: Merge joins on index scans