Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i7HBa-0004Yr-M2 for pgsql-performance@arkaria.postgresql.org; Mon, 09 Sep 2019 10:46:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1i7HBZ-0003al-I1 for pgsql-performance@arkaria.postgresql.org; Mon, 09 Sep 2019 10:46:17 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i7HBZ-0003WO-30 for pgsql-performance@lists.postgresql.org; Mon, 09 Sep 2019 10:46:17 +0000 Received: from mail-io1-xd41.google.com ([2607:f8b0:4864:20::d41]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i7HBV-0004dG-UW for pgsql-performance@lists.postgresql.org; Mon, 09 Sep 2019 10:46:16 +0000 Received: by mail-io1-xd41.google.com with SMTP id n197so27492773iod.9 for ; Mon, 09 Sep 2019 03:46:13 -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=W6yWLdsKoYFUzAAOes13HW8XU11B26TaGC87uZxJVNc=; b=gb/u8JUDu4ER8XMleeQ5Xe95ZPnum847YAMZwVCxPrPDYjeveO57UYmGn37DIbDRNm m2mNMwcCJZe8GSUuoP7fM5jKWMCkdtB5qDCIgIdGB9C+E7jnaVqyJA+LVJWpfWcAnhKQ RMwHL1xy+hj6sCk1/2VHCOkVl+1NiwDT5gQ0dvesBm7hpMgC0Lvsv6wl4pjlWZ3iK8Vi AODhR76MGGMlCmeZ0Y5LOASYG75OF085MpDlSDNsdJO3xi4tfZA74XgvxpXyLKHpULZU CVjl0cD3IOzWi4lsNe2Ej1PQnZiLF4ZeBWRUCOudCQEw/2GkZ+GUWG/jmOaCZkJEDdta NMLA== 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=W6yWLdsKoYFUzAAOes13HW8XU11B26TaGC87uZxJVNc=; b=aok15drqL2JXKZbNoU1IrvN5edTB7ZIMss+lgfzBFXHocAawZ5a2JxX+gU4mK6ZRlp tCGwMYaKCO7A8B/jUBMSfmzRG9zxVHMSCbLs3lOFlayFkV2mhXOq/eLWAx/IPIuiTuNb C/FzaWgiBDcuVX2X16KTNjNVcySSPq6uVB0P33achoFbLLTnwMeiNDU6ycr+hu7tbeS8 wtrqbKQgkf4NXu5GbKAmDpIsUYJTU+scOtoTK7HDkiIVAEroRAuheEvpIs1eyVbq6jrd ujdbJKgVUHYgTJRaWNG64mBP1o30DdrWaEqGl3sroHYXVXZMTMfZ80bD3kONStY2WbUz PrDw== X-Gm-Message-State: APjAAAXH5I+TAnhXiaE/808R3DMvHdLn7LiTPwEpnzfv0YNY0oJ/vWPF aUU43PtY/CRCS55HYETFwbOdgtpY+T8= X-Google-Smtp-Source: APXvYqxOU+GIPNTu3G2LpvP9dv4zACdXbuiZhdRvP56BBizo2sgOrwICplrHVybc/5F+tT5VOEDV1w== X-Received: by 2002:a5d:8504:: with SMTP id q4mr4318564ion.220.1568025572378; Mon, 09 Sep 2019 03:39:32 -0700 (PDT) Received: from pryzbyj (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id k17sm10871524ioc.30.2019.09.09.03.39.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Sep 2019 03:39:31 -0700 (PDT) Received: by pryzbyj (Postfix, from userid 1000) id 7B862800969; Mon, 9 Sep 2019 05:39:30 -0500 (CDT) Date: Mon, 9 Sep 2019 05:39:30 -0500 From: Justin Pryzby To: yash mehta Cc: pgsql-performance@lists.postgresql.org Subject: Re: select distinct runs slow on pg 10.6 Message-ID: <20190909103930.GP7201@telsasoft.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Mon, Sep 09, 2019 at 02:00:01PM +0530, yash mehta wrote: > We have a query that takes 1min to execute in postgres 10.6 and the same > executes in 4 sec in Oracle database. The query is doing 'select distinct'. > If I add a 'group by' clause, performance in postgres improves > significantly and fetches results in 2 sec (better than oracle). But > unfortunately, we cannot modify the query. Could you please suggest a way > to improve performance in Postgres without modifying the query. Not sure it helps, but I remember this: https://www.postgresql.org/message-id/CAKJS1f9q0j3BgMUsDbtf9%3DecfVLnqvkYB44MXj0gpVuamcN8Xw%40mail.gmail.com