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 1gfCiT-0008Fq-5f for pgsql-performance@arkaria.postgresql.org; Thu, 03 Jan 2019 23:47:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gfCiR-00087v-KU for pgsql-performance@arkaria.postgresql.org; Thu, 03 Jan 2019 23:47:55 +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 1gfCiR-00087n-8t for pgsql-performance@lists.postgresql.org; Thu, 03 Jan 2019 23:47:55 +0000 Received: from mail-it1-x144.google.com ([2607:f8b0:4864:20::144]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gfCiJ-0002Dv-TN for pgsql-performance@lists.postgresql.org; Thu, 03 Jan 2019 23:47:54 +0000 Received: by mail-it1-x144.google.com with SMTP id p197so44911518itp.0 for ; Thu, 03 Jan 2019 15:47:47 -0800 (PST) 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=xqBSDP2aBphkNFhA1jg4ItjliXKx6cCWlLZ5M+OMdCs=; b=1VxgFrwPY6lOxh5rva5ZduzqDmZYFd7nyarGYngtxnhblZv2cfiBtMdER+0Xw7No0N xyNm9n25ypwBacgNRgftOjIA+9FdDQGghDVLUdBXDdKckq19Oe9vjFmNXYYjtmZ2NFne eakcyDqSDBPWeMoJgaxfhzt2/dogOPK0UWYwXDxJUrg2jLe80r0XGPOaCVGn54LUz0Hq rUv+InoQvl6mLb1ngSF4TNxE8zeqGiZ/a9fF4q6NJC544hn84vNzSRnkRkJGHqzUnSWC 5xMVDFw5GXXOmkPg25ZiNT+qtiRSkQrYuhqNgVE2ulZ2VXQpipmgPFVECoFzIf7RRz4E rLkw== 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=xqBSDP2aBphkNFhA1jg4ItjliXKx6cCWlLZ5M+OMdCs=; b=YhZ49K6kt/rJsrd/vQXlJnfh3xGiuFHAarTWRR1QB5ykWK5b5eX9cPu+UMfiBtWm7I ce7sAC1KuZdXsNs5y6EoRfcfb0DhYtDjVlrMO9n09zpjtHADP05/fwfvQB9FJJ2uPyVR qxza5cQxnCZFgPzH+Pl2FsoKvcJPUZ1zqMMU+YTL+SDcA26YEEyQQaWHCdKaXtouVilZ RM3Foeywwjpe9zH+upPztSMFulLdjt8cmXBi/RKHc0p2vAE3Kxeqr1GRsS0PX8Z5tRKr vZnfdTud+ublG8ZtH5DPxVw9D5F36NcvzDEWXjogfw9SLB/SlZ39lVvav2eVrC+dR1Cz MVKA== X-Gm-Message-State: AJcUukf4yuPFCYlghirEFA7B6PWcY7tEe8uBZhFQcXOeiDnyqJDLVxEc 6cug4zrxVJgHFreXi9X7GN3a6w== X-Google-Smtp-Source: AFSGD/WOY38tI8POPJngQGx//HOrr5TMmBQT2c6Yf16l8q8W5ZqWHq+ajL5YwlV4Mnwxvwr8dfy0DA== X-Received: by 2002:a24:9646:: with SMTP id z67mr31589771itd.153.1546559265892; Thu, 03 Jan 2019 15:47:45 -0800 (PST) Received: from pryzbyj (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id 197sm23845093itx.21.2019.01.03.15.47.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Jan 2019 15:47:45 -0800 (PST) Received: by pryzbyj (Postfix, from userid 1000) id 69A5380073E; Thu, 3 Jan 2019 17:47:43 -0600 (CST) Date: Thu, 3 Jan 2019 17:47:43 -0600 From: Justin Pryzby To: Abadie Lana Cc: David Rowley , "pgsql-performance@lists.postgresql.org" Subject: Re: select query does not pick up the right index Message-ID: <20190103234743.GU25379@telsasoft.com> References: <49406fb0c239480980ffc6c2a250d4e9@iter.org> <438dcc57f91d4a9fab12ae4078592d69@iter.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Thu, Jan 03, 2019 at 12:57:27PM +0000, Abadie Lana wrote: > Main parameters : effective_cache_size : 4GB, shared_buffers 4GB, work_mem 4MB I doubt it will help much, but you should consider increasing work_mem, unless you have many expensive queries running at once. Could you also send the rest of the pg_statistic for that table ? https://wiki.postgresql.org/wiki/Slow_Query_Questions#Statistics:_n_distinct.2C_MCV.2C_histogram SELECT (SELECT sum(x) FROM unnest(most_common_freqs) x) frac_MCV, tablename, attname, null_frac, n_distinct, array_length(most_common_vals,1) n_mcv, array_length(histogram_bounds,1) n_hist FROM pg_stats WHERE attname='...' AND tablename='...' ORDER BY 1 DESC;