Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nXMVs-00029d-Iy for pgsql-performance@arkaria.postgresql.org; Thu, 24 Mar 2022 12:24:24 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nXMVr-0002Wu-1r for pgsql-performance@arkaria.postgresql.org; Thu, 24 Mar 2022 12:24:23 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nXMVq-0002Wl-Kh for pgsql-performance@lists.postgresql.org; Thu, 24 Mar 2022 12:24:22 +0000 Received: from mail-io1-xd2f.google.com ([2607:f8b0:4864:20::d2f]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nXMVm-0006dh-7M for pgsql-performance@postgresql.org; Thu, 24 Mar 2022 12:24:20 +0000 Received: by mail-io1-xd2f.google.com with SMTP id 125so5139926iov.10 for ; Thu, 24 Mar 2022 05:24:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=wpG9kjlMJdb0tXrhqpSWrJ2Age2zP14eFljYGMUdzQY=; b=3hIxyBARcIYcqVk9jKNdOKEe1hM6+dyTmAGXEe7N6TvjzB4KAUpkhLZWLRZ98006Gp Y70BjSEQTpXHl/39OU03/rCcpo2pO8haKcxIR2Bd0vo0ZDFtrvsZpVTZNKQ5t1qWGt4c AEGus0zRK2QzMCzByA4T5fgf0UAKA4Hkdb1nfPp17GJFMcrutybnoxfPyPR26q+FLnaX PpVHInYl2S7voNgXNodV9vdCoH8rDmTiLXmMpoUj2YkCnAZuI9TMmXclOC8NKpXHd7E7 4nR6cSZK+sfl6puCZU7/kCt7I6Pl86TiRkh1Y8oLSDevzDGdxZbgFSH7Rg1Ai8J7YJ2s AU8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=wpG9kjlMJdb0tXrhqpSWrJ2Age2zP14eFljYGMUdzQY=; b=xewq0iUMDAm8eTigeQp6a3WsrvK/0ebqCF6ZPvpp40k6N4t28po9QKYPBbHi7C7ywe gQTA9EIMQI5lH4x1hzGbyaSK5jmlF2rzg/RepUlFJtH7Ah4Q5VLLhBEJfJqV2gD018ue p2jJTtgdNzxbIQmV3YiuGw+4JQobKHbbWSruR/Gz/DZQ5QiAv8j4JRT8aWtbE3V6qMNW h2tdOQkYIa+2hB4nxRhBBTtyZMkN8usRt3cP3yV0S1avI1aIaM7CO0jqUf0u46+dG3it pLx1KWgokKW0gOfVJSbUAxo6w0n9CzAIEumWZ7Av1u0GrWbw+RySqTAI6zJHnJagHj6Z vpvQ== X-Gm-Message-State: AOAM531THdSWepAvax1DFxudDmyCHfB9GR3Q5AU5MsdevanD0G4cRoP8 58nhtc1gHu4g6DfgdU4p3au0Uw== X-Google-Smtp-Source: ABdhPJwOnHHUx2gQlVuk9zzCq8UwIlUu1p50vcwVUzp/cz0hqKpJ0eOPMnKcyF6crEq3U5r5ri5j8Q== X-Received: by 2002:a05:6602:2b0b:b0:60f:6c6f:d114 with SMTP id p11-20020a0566022b0b00b0060f6c6fd114mr2632776iov.157.1648124655908; Thu, 24 Mar 2022 05:24:15 -0700 (PDT) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id d14-20020a056602184e00b00649673c175asm1406275ioi.25.2022.03.24.05.24.15 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Mar 2022 05:24:15 -0700 (PDT) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id 8A813800785; Thu, 24 Mar 2022 07:24:14 -0500 (CDT) Date: Thu, 24 Mar 2022 07:24:14 -0500 From: Justin Pryzby To: Prajna Shetty Cc: Tom Lane , pgsql-performance@postgresql.org, Beenu Sharma , Pranabesh Saha , Surya Susai Subject: Re: Performance issue post upgrade on Version 13 - Incorrect Estimation Cost choosing Hash Aggregate-Nested Left Loop Join Message-ID: <20220324122414.GZ28503@telsasoft.com> References: <1872582.1647871148@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, Mar 22, 2022 at 12:57:10PM +0000, Prajna Shetty wrote: > 1. We have performed Vacuum/Analyze/Reindex post Upgrade. > 2. Tweaked work_mem so it does not spill to Disk. We can Disk Usage But it is still using Hash Aggregate and came down from 5 minutes to 20 seconds. (Expected ~5 seconds). Attached plan after modifying work_mem > 3. Disabled Seqcan/ nestedloop > 4. Tweaked random_page_cost/seq_page_cost > 5. Set default_statistics_target=1000 and then run vacuum(analyze,verbose) on selected tables. > 6. We have also tested performance by increasing resources up to 4 vCPU and 32 GB RAM. Would you provide your current settings ? https://wiki.postgresql.org/wiki/Server_Configuration