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 1nMcgp-0001BF-Ab for pgsql-performance@arkaria.postgresql.org; Tue, 22 Feb 2022 21:27:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nMcgn-00062m-PP for pgsql-performance@arkaria.postgresql.org; Tue, 22 Feb 2022 21:27:17 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nMcgn-00062c-BM for pgsql-performance@lists.postgresql.org; Tue, 22 Feb 2022 21:27:17 +0000 Received: from mail-io1-xd32.google.com ([2607:f8b0:4864:20::d32]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nMcgk-000215-4L for pgsql-performance@postgresql.org; Tue, 22 Feb 2022 21:27:16 +0000 Received: by mail-io1-xd32.google.com with SMTP id m185so21975336iof.10 for ; Tue, 22 Feb 2022 13:27:13 -0800 (PST) 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=E8PpgnlQSOyRzss1LSbBD6ReVEh9yD8oAwLEBPca03M=; b=c5RS89hPKpZRhZOX4vs1DpPOuHm/Pw73aZ48K+WYo5LagirukoFIv0CWYlq0ET2U4a 7pFtt1szlJRUJ0WuvMqRXmMelWftB5gcyYL6CKehnrj9Ux0JaMSe9LnYOMbBhPUdoPFQ qx9Ru/NP0qRKkztY5RzsKn6RMXU1imTi35dLtfbwKQB4DByM2MiS5DXHwTfa5IdPGg0b Z6BxMOAcmd1EjwZy5dH/9m/JJgfW8SXoHZ2qRbcW3xRsTQArC1dx92Y95iA04WrIgNHk dv6A/1n7ntLeT7UL6S16a/2WWMxkRbb+U6tg2qaEXv9nsZOv5eGblOuzN2gxgALQOluF Gs+A== 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=E8PpgnlQSOyRzss1LSbBD6ReVEh9yD8oAwLEBPca03M=; b=0u6YVtTRAG0FOQlOCI28EEHiVDsJIG+akKnyKPyoOzJRvaKY2TjUbiffhZ0UNFkzXr sMHkVWP8Gw2K9gbISwOhwzJKqhQm/KSxqijRrOlrEhr6lfdgtx1na1ofllm6eDLG0SIb /YUuhGP0Z48vbf4Auty6Q2V0TRmEgx3tpTewGgKSiTxT0E2vx++k1GNiY9EfgvGmLb7b qTW1GGHsIYmw+n9obpi14UDUtfkKyE4E2+4JEECjlbTVbO25qC/vUIkA7F9sRs5/BEc2 RNPAISjK22VSBFRpCyBa92UeUENZzkROTiJ7UygA3gU/braYPv/VtpvoJ/jokXkFHDlP oP/A== X-Gm-Message-State: AOAM5316nykrs6Dkhi1b+NXy6MAFDGp13NYLogV6YwC/PGfVPwRjZ9O+ i9tm9302j5sXe0q4KAROCg53lA== X-Google-Smtp-Source: ABdhPJzDUiMd7oem8qENls5IX66Lx0KAxRN1EVpVIClXr6kl+sxQb+toE4kt6GC7wzj5tBSKNi2Pvg== X-Received: by 2002:a05:6638:bcd:b0:314:9138:8344 with SMTP id g13-20020a0566380bcd00b0031491388344mr19849695jad.64.1645565232721; Tue, 22 Feb 2022 13:27:12 -0800 (PST) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id m1sm11132699ilu.87.2022.02.22.13.27.11 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Feb 2022 13:27:12 -0800 (PST) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id CEB0080057D; Tue, 22 Feb 2022 15:27:10 -0600 (CST) Date: Tue, 22 Feb 2022 15:27:10 -0600 From: Justin Pryzby To: "Kumar, Mukesh" Cc: pgsql-performance@postgresql.org Subject: Re: Slow Running Queries in Azure PostgreSQL Message-ID: <20220222212710.GI9008@telsasoft.com> References: 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, Feb 22, 2022 at 02:11:58PM +0000, Kumar, Mukesh wrote: > -> Hash Join (cost=6484.69..43117.63 rows=1 width=198) (actual time=155.508..820.705 rows=52841 loops=1)" > Hash Cond: (((lms_doc_property_rights_assoc.doc_sid_c)::text = (lms_doc_propright_status_assoc.doc_sid_c)::text) AND ((lms_property_rights_base.property_sid_k)::text = (lms_doc_propright_status_assoc.property_sid_c)::text))" Your problem seems to start here. It thinks it'll get one row but actually gets 53k. You can join those two tables on their own to understand the problem better. Is either or both halves of the AND estimated well ? If both halves are individually estimated well, but estimated poorly together with AND, then you have correlation. Are either of those conditions redundant with the other ? Half of the AND might be unnecessary and could be removed. -- Justin