Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1duo41-0004DR-VG for pgsql-performance@arkaria.postgresql.org; Wed, 20 Sep 2017 23:05:54 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1duo41-0008LT-GO for pgsql-performance@arkaria.postgresql.org; Wed, 20 Sep 2017 23:05:53 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1duo40-0008I4-Hr for pgsql-performance@postgresql.org; Wed, 20 Sep 2017 23:05:52 +0000 Received: from mail-vk0-x22e.google.com ([2607:f8b0:400c:c05::22e]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1duo3t-0000lU-IF for pgsql-performance@postgresql.org; Wed, 20 Sep 2017 23:05:51 +0000 Received: by mail-vk0-x22e.google.com with SMTP id o22so2253644vke.1 for ; Wed, 20 Sep 2017 16:05:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=fC5JnvespPpdA5RHhEBnA3HaXNLAEKLXJp6C2hNtCNM=; b=r585Zujfrie9/zWTwd8kWHLoZrhEDrYDsParGukz1ip3UbOD6tgVgfO4gBxdNKZ7fr Dpcsoil5aMSiL3I1cWzfJz1Zyh6M/zTmA8MZ93UmooGOADWKJtXtWeQ7Mw14ShiOfhfD lWWTqb3FhURZfjOi4E9FPCbbG0bL1XPdlLexnnRIgGg7Fxx3819E6mA+87ohqR8TxRN/ CWmvXjBED66FyzTS/zZ/PQ65xAIZSbsV42UZE+KWvMFUzTygsuuaFeHhndMf9h24fsLm 9n93QHNjF6AJSkbxc909ZmViDj+gGAhqtbvS0dZm4BZMchPRHaug2ETKzRu//wPayk4P sOZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=fC5JnvespPpdA5RHhEBnA3HaXNLAEKLXJp6C2hNtCNM=; b=A+Ix2+criJo2B5qHDNDWwNRpm7AO07AlVnQv0riFWdxU114Ajb4zSqgtR+lLwbWi8K 3z3QNjAcVP/AJrYpvX0NAx9yJYS6gb1hWYecPRbk2RBqhta3oh1wk8saZEQOni3kW9qd 62ANTWRmbs0KYPB6RZvZGqJSw1XXylIi5UlnlUI9t241W9VlyMwQfJcPq0LGwyD3KwqG X7WPIW8sYlbwOh9DO+bDX9Dq9pPfJ15kHVoL0MM1oRSwmhupTdGzozxmfD1H9mNxO63d UrXOK4hBkomSn3imUU80TI2B00p/7dm3Q4bqOjxVYQQcsDkOVrymHsvd1QstbS8vkXc3 NA8A== X-Gm-Message-State: AHPjjUgaSj8qC98xuIe+E8WwGH5w2LOoMGkQjP0eWxsUC9ZwZF2p7glw Ethb+it5KKyzu8cu7iMfmDnA1GASinU3NEqLoIPm7s0i X-Google-Smtp-Source: AOwi7QDKZdw2yZBeLbveG+xG6tDbLf8zLz4lEwOipc43qbo7rDrFlWaO3UuqyDR5Xa84p6npxThTZ2S8joG2Irie+wY= X-Received: by 10.31.79.199 with SMTP id d190mr271796vkb.186.1505948743897; Wed, 20 Sep 2017 16:05:43 -0700 (PDT) MIME-Version: 1.0 Received: by 10.176.82.97 with HTTP; Wed, 20 Sep 2017 16:05:43 -0700 (PDT) In-Reply-To: References: <3138.1505508143@sss.pgh.pa.us> From: David Rowley Date: Thu, 21 Sep 2017 11:05:43 +1200 Message-ID: Subject: Re: query of partitioned object doesnt use index in qa To: Mike Broers Cc: Tom Lane , postgres performance list Content-Type: text/plain; charset="UTF-8" List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org On 21 September 2017 at 04:15, Mike Broers wrote: > Ultimately I think this is just highlighting the need in my environment to > set random_page_cost lower (we are on an SSD SAN anyway..), but I dont think > I have a satisfactory reason by the row estimates are so bad in the QA > planner and why it doesnt use that partition index there. Without the index there are no stats to allow the planner to perform a good estimate on "e.body->>'SID' is not null", so it applies a default of 99.5%. So, as a simple example, if you have a partition with 1 million rows. If you apply 99.5% to that you get 995000 rows. Now if you add the selectivity for "e.validation_status_code = 'P' ", let's say that's 50%, the row estimate for the entire WHERE clause would be 497500 (1000000 * 0.995 * 0.5). Since the 99.5% is applied in both cases, then the only variable part is validation_status_code. Perhaps validation_status_code = 'P' is much more common in QA than in production. You can look at the stats as gathered by ANALYZE with: \x on select * from pg_stats where tablename = 'event__99999999' and attname = 'validation_status_code'; \x off -- David Rowley http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance