Re: Unexplainable execution time difference between two test functions...one using IF (SELECT COUNT(*) FROM...) and the other using IF EXISTS (SELECT 1 FROM...)

From: Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Hackety Man <hacketyman(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Pgsql Performance <pgsql-performance(at)lists(dot)postgresql(dot)org>
Subject: Re: Unexplainable execution time difference between two test functions...one using IF (SELECT COUNT(*) FROM...) and the other using IF EXISTS (SELECT 1 FROM...)
Date: 2018-04-17 10:52:45
Message-ID: 3fa6c3a7-e85e-8dc5-35b5-70b06f86ffd0@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On 04/17/2018 07:17 AM, Pavel Stehule wrote:
> Hi
>
> 2018-04-16 22:42 GMT+02:00 Hackety Man <hacketyman(at)gmail(dot)com
> <mailto:hacketyman(at)gmail(dot)com>>:
>
> ...
>
> A support of parallel query execution is not complete -  it doesn't work
> in PostgreSQL 11 too. So although EXISTS variant can be faster (but can
> be - the worst case of EXISTS is same like COUNT), then due disabled
> parallel execution the COUNT(*) is faster now. It is unfortunate,
> because I believe so this issue will be fixed in few years.
>

None of the issues seems to be particularly related to parallel query.
It's much more likely a general issue with planning EXISTS / LIMIT and
non-uniform data distribution.

regards

--
Tomas Vondra http://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Akshay Ballarpure 2018-04-17 12:24:12 RE: Data migration from postgres 8.4 to 9.4
Previous Message Tomas Vondra 2018-04-17 10:49:29 Re: Unexplainable execution time difference between two test functions...one using IF (SELECT COUNT(*) FROM...) and the other using IF EXISTS (SELECT 1 FROM...)