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 1lf391-0004wO-7G for pgsql-performance@arkaria.postgresql.org; Fri, 07 May 2021 16:16:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lf390-00039M-5x for pgsql-performance@arkaria.postgresql.org; Fri, 07 May 2021 16:16:02 +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 1lf38z-00039D-PC for pgsql-performance@lists.postgresql.org; Fri, 07 May 2021 16:16:01 +0000 Received: from mail-ot1-x333.google.com ([2607:f8b0:4864:20::333]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lf38t-00087c-Nf for pgsql-performance@lists.postgresql.org; Fri, 07 May 2021 16:16:00 +0000 Received: by mail-ot1-x333.google.com with SMTP id c28-20020a9d615c0000b02902dde7c8833eso3404760otk.7 for ; Fri, 07 May 2021 09:15:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=jg1UKlMrCZOBXw7J198ihmBN38Xl8jpQHjWry2O/YD8=; b=1PWrfARGrZgg2PpIJyi3JEZML2j7ZAW0IFgVEWiV5twukDjHxSU/RWpfhnsna+lAD2 dzgSRNgXZb+RarIrVmWyCv2kZV6n8hVRLhxoHYXBnS4NYfuC4NE+bHTICJtwfydgdYrq eBClmVxwLt2qHY7CNtTWiks2xN6iwtNRBh3QA+vEHncjt7Xh6GiyhlNB6NONNL6tsp+h lke4ihROjikhQ5UbJaU6LGC6eD+nIDWnhJIxaC0n8KgTwkYe2SL/jKPzcrOPJENc9VPY 2PEgvh6mhKBbyTga1x682YZoug0ylBPjX0CWrn0oaNMnedvEfrYJbqeYB1RnezVwwmBA jn+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=jg1UKlMrCZOBXw7J198ihmBN38Xl8jpQHjWry2O/YD8=; b=cVJDfdxOOc0NMS+m65ZdnVGgBSZ9Z4AGXVIFQeGQIv1c0a1IdgjUy+WGRnCyY+zGuL QbtY/A6ut4xSEHkmcpUrH9oByAIlTiVHMurTVCDHzj73oVZOsuPMTCaZn/B3CRoFfPdN Vc8NC4zaelyNwsY1t6AOKeN1e0A7IiEbcIeNUfDzF7suXgmVM1th1u8VXc6LH1ivNGpR bjFZqR7HEB598pfprKZasWzalmET+7daa5XhCTVVR4810AuylasgaRUdE+j86IWUlGp9 Obok5ElbwVWnd+RvRgZqLwhv3I5uW/EdtGZy0O9QGw8mPdqqnVfIm8mq+OmobzddXn4w JU5g== X-Gm-Message-State: AOAM530Jv5hk9jqUV6G++eHXxKwgPEBKV2yfXHhBZOjr0gxx3+0lrbUW jKvcbus2YyNuLofZfGSpTCEbGw== X-Google-Smtp-Source: ABdhPJzHK1ctQsks3KCM6WA8TnoqW5420fzs4iBMmX3DQsywYisFD9vZFLWlLPvhiPRlhigd/D4ggA== X-Received: by 2002:a9d:7dc8:: with SMTP id k8mr9147386otn.138.1620404153149; Fri, 07 May 2021 09:15:53 -0700 (PDT) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id x24sm1274620otq.34.2021.05.07.09.15.52 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 May 2021 09:15:52 -0700 (PDT) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id 4350E8008F8; Fri, 7 May 2021 11:15:51 -0500 (CDT) Date: Fri, 7 May 2021 11:15:51 -0500 From: Justin Pryzby To: Semen Yefimenko Cc: Vijaykumar Jain , pgsql-performance@lists.postgresql.org Subject: Re: Very slow Query compared to Oracle / SQL - Server Message-ID: <20210507161551.GT27406@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 Fri, May 07, 2021 at 05:57:19PM +0200, Semen Yefimenko wrote: > For testing purposes I set up a separate postgres 13.2 instance on windows. > To my surprise, it works perfectly fine. Also indexes, have about 1/4 of > the size they had on 12.6. In pg13, indexes are de-duplicated by default. But I suspect the performance is better because data was reload, and the smaller indexes are a small, additional benefit. > This explain plan is on a SSD local postgres 13.2 instance with default > settings and not setting random_page_cost. > -> Parallel Bitmap Heap Scan on schema.logtable (cost=61.84..16243.96 rows=1845 width=2638) (actual time=0.350..2.419 rows=2362 loops=3) > Output: column1, .. ,column54 > Recheck Cond: ((logtable.entrytype = 4000) OR (logtable.entrytype = 4001) OR (logtable.entrytype = 4002)) > Filter: (logtable.tfnlogent_archivestatus <= 1) > Heap Blocks: exact=2095 > Buffers: shared hit=2109 In the pg13 instance, the index *and heap* scans hit only 2109 buffers (16MB). On your original instance, it took 300k buffers (2.4GB), mostly uncached and read from disk. > This will still take some time so I will update once I have this tested. > Seems like there is something skewed going on with the development database > so far. I still think you should try to cluster, or at least reindex (which cluster also does) and then analyze. The bitmap scan is probably happening because 1) you're reading a large number of tuples; and, 2) the index is "uncorrelated", so a straight index scan would randomly access 300k disk pages, which is much worse even than reading 2400MB to get just 16MB of data. -- Justin