Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f8OEI-0002mh-Dw for pgsql-performance@arkaria.postgresql.org; Tue, 17 Apr 2018 10:52:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f8OEH-00025C-2l for pgsql-performance@arkaria.postgresql.org; Tue, 17 Apr 2018 10:52:53 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f8OEG-000253-Jz for pgsql-performance@lists.postgresql.org; Tue, 17 Apr 2018 10:52:52 +0000 Received: from mail-wr0-x22d.google.com ([2a00:1450:400c:c0c::22d]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1f8OED-0006YM-Gw for pgsql-performance@lists.postgresql.org; Tue, 17 Apr 2018 10:52:51 +0000 Received: by mail-wr0-x22d.google.com with SMTP id q13so30779836wre.3 for ; Tue, 17 Apr 2018 03:52:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=SH0rKuuvsnabO97lApuqdcHRz1jVHnnrUTeVejkKe5Y=; b=C0JN47mlrbER8qNAjN5bnyC/OeSGRVHLkJQcsb7b+4B3+ugs1s1Ss3CMx/Ro/F5ubS Gz9TiJnDCqyMFh7CiupZ8uarJdjEniDeTUZWq1PZoTPjaEIN07H+kUlGqfU079C9y4nM b4o0e0YJFLEvDL0I5ZdDz+VnUDVzwYspo0nbXyn6GaYdgNR5eP6bVjnqIt1XLGWguBrR OPFZrXZt1A02GVEV/a/7MHB0IjEll1pAeENFl0rIIKOdLf119qmy1CCmXSXa4lYtRhjb YUOaCjIwheKIlyRJ6VY2jr+0kV7g7EgSpaax3lng02GrukFq/diCTPJbFrlSPZM1Qz1T r+nQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=SH0rKuuvsnabO97lApuqdcHRz1jVHnnrUTeVejkKe5Y=; b=H4n6j+AmJ/CMuuha3NCq3+ByFGsFUOsCBospVGWuEZFm9628gdrNzktKmR6Kj1y1e9 MclgqHFS8y0haUyoAFKlXBI0U1hoiJZDuO5WlkOsM1HTwzDGe60E7TuvfhWlXBPXXqZ0 ASNuncfdzOMYHoF7qz202D+y6SW5nwyg1dsfN+Ofw1y+HQPcCRyvVr0YYPJ3GZBzt7Kw 1i7mneGNf6cxE8Tc1G9v1O7xDOlGTDJGMAy/KlpuxG73JOA383q1UrjCBJ5Qvf7FDniC lpv0ei50ONWBZUc3GgdqN9VVnXkBYfsEoPSQeXUpqotqkiy7db7A5E9COb8N7O4lFym4 7FEw== X-Gm-Message-State: ALQs6tCQBsIRWXJT6HdSnJeSWH9ss2bwUMFJa2lbSzWWsMz8Difsst2m mKpgmTqA6ZFBKJBEFs0EwcXQQoHub9iiMyO86ds9ABpvltBHvfdIrxIQa7BEMgbenEwa1kDb5Rt rtcUYlPIo1egTmco1/U90bRFykxiYJWpEEEySsAl18iT6dHtWHHEsGgkeAOox+pkT2daDe0lcVC wy8Wpn5u6Tni21oEImkWKlHg== X-Google-Smtp-Source: AIpwx4+VD5fwEZHOskuRGiCBQaUuuToigoYZkyrNhTjChcPYFEOO0nbV04ICDP+Gwum354Re5r8Xww== X-Received: by 10.223.196.182 with SMTP id m51mr1309527wrf.126.1523962367550; Tue, 17 Apr 2018 03:52:47 -0700 (PDT) Received: from [10.137.2.21] ([212.24.157.174]) by smtp.gmail.com with ESMTPSA id b5sm6200574wrh.67.2018.04.17.03.52.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Apr 2018 03:52:46 -0700 (PDT) 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...) To: Pavel Stehule , Hackety Man , Robert Haas Cc: Pgsql Performance References: From: Tomas Vondra Message-ID: <3fa6c3a7-e85e-8dc5-35b5-70b06f86ffd0@2ndquadrant.com> Date: Tue, 17 Apr 2018 12:52:45 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 04/17/2018 07:17 AM, Pavel Stehule wrote: > Hi > > 2018-04-16 22:42 GMT+02:00 Hackety Man >: > > ... > > 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