Re: Apply LIMIT when computation is logically irrelevant

From: Michael Lewis <mlewis(at)entrata(dot)com>
To: Robins Tharakan <tharakan(at)gmail(dot)com>
Cc: PostgreSQL General <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Apply LIMIT when computation is logically irrelevant
Date: 2020-07-06 19:51:36
Message-ID: CAHOFxGqETwver1DDy-pcZT3+Z8fw+yyiuLwCC-rNAF1rA9ayqg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Jul 6, 2020 at 5:37 AM Robins Tharakan <tharakan(at)gmail(dot)com> wrote:

> This need came up while reviewing generated SQL, where the need was to
> return true when
> at least one of two lists had a row.
>

Generated SQL... yep. That will happen. Manual SQL may be more work, but
often has significant reward.

If you can change how the SQL is generated, I would expect that EXISTS
would likely be more performant in your case, even if you need to do UNION
ALL between the two current queries that potentially return true.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Michael Lewis 2020-07-06 19:55:00 Re: Is postgres able to share sorts required by common partition window functions?
Previous Message Sebastien Arod 2020-07-06 16:43:31 Is postgres able to share sorts required by common partition window functions?