Re: Perfomance of IN-clause with many elements and possible solutions

From: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
To: Dmitry Lazurkin <dilaz03(at)gmail(dot)com>
Cc: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Perfomance of IN-clause with many elements and possible solutions
Date: 2017-07-31 16:42:50
Message-ID: CAMkU=1we8pXTzUaxY7d7T7ww9s74sjU+mje=yHi=8gH7Zix6Pg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Jul 24, 2017 at 3:12 PM, Dmitry Lazurkin <dilaz03(at)gmail(dot)com> wrote:

> On 25.07.2017 00:31, David G. Johnston wrote:
>
>
> Basically you want to write something like:
>
> SELECT *
> FROM ids
> JOIN ( :values_clause ) vc (vid) ON (vc.vid = ids.id)​
>
> or
>
> WITH vc AS (SELECT vid FROM .... ORDER BY ... LIMIT )
> SELECT *
> FROM ids
> JOIN vc ON (vid = ids.id)
>
>
> This query uses JOIN plan node as IN (VALUES ...).
>
> And I have one question. I don't understand why IN-VALUES doesn't use
> Semi-Join? PostgreSQL has Hash Semi-Join... For which task the database
> has node of this type?
>
>
I think it is simply because no one has gotten around to implementing it
that way. When you can just write it as a values list instead, the
incentive to make the regular in-list work better is not all that strong.

Cheers,

Jeff

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jeff Janes 2017-07-31 17:08:47 Re: Perfomance of IN-clause with many elements and possible solutions
Previous Message Thomas Güttler 2017-07-31 10:45:24 Re: Row based permissions: at DB or at Application level?