Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dlGmo-00036Z-6v for pgsql-performance@arkaria.postgresql.org; Fri, 25 Aug 2017 15:44:42 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dlGmn-0008B0-Pm for pgsql-performance@arkaria.postgresql.org; Fri, 25 Aug 2017 15:44:41 +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 1dlGml-00080L-Uq for pgsql-performance@postgresql.org; Fri, 25 Aug 2017 15:44:40 +0000 Received: from mail-it0-x235.google.com ([2607:f8b0:4001:c0b::235]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1dlGmj-0004tu-2V for pgsql-performance@postgresql.org; Fri, 25 Aug 2017 15:44:38 +0000 Received: by mail-it0-x235.google.com with SMTP id 77so986460itj.0 for ; Fri, 25 Aug 2017 08:44:36 -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:content-transfer-encoding:in-reply-to :user-agent; bh=mJ/TAnG5mmhoZ1SLMheL0yB40e8QMeR8aEBJOAOdcaU=; b=WZDki2FqN3k18bDScg8Zp/6Cb3i8JxT8YO7x9dj9MDh6MEQU91p9Dje6ZLEsQZIbdm /mcGdkGjyolC5bx7xtds0r63amajXRDZGI+cOOndILayrZc5yTzj8uLfV9dUV899yvkV 0n16O4Pwg1PvYPv2s+BcWotumGn5gTUQ2mLS8frWgwfE36A7c11dPVEG1hm65ookKnw1 8Lwgnq40gH9DR40EXZJcJUjJ9yCn2mVSkFqCTyaz41kcWTxZ22m8+9evCWqtnRDhfWkH TAH9/zMPbt0arjhwQW6UAkXJ/+w47ZAujBQ2XLFXv8PL8Sig7S+4IJ7Q0wsa6TK/quEC vrfA== 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:content-transfer-encoding :in-reply-to:user-agent; bh=mJ/TAnG5mmhoZ1SLMheL0yB40e8QMeR8aEBJOAOdcaU=; b=DNjaTasH7XRGrnHb0NFbN97utuIemHJwoqn7tkjeyirNx0VbiQwMxGDzZrDsCSdGGe t++6DqS9VbBixrIm+usy+EBpLXAI5oxeUCa+HNariPlkCU/5IY/nWbNUb+1brD2AofWA ZIFBbZeCO0RJUMtTmAgjPCJmSRYxvx53CIqlEp7R6QyPxIEOAD55eJYhZFQ4Yk9G0gHZ GfIhMqzWOUv/twjDrX2zQsdTnamEpxMayspCDq6n3hYZa/yBJgtxerIa9xPR+3EW3xQN +BSbk5cS4e0e4ZyVTEE/IZV5qtCxbXBVhoXijVAW7xSzoKHghhDY7BHABnYm0Q0TpAH0 lb5g== X-Gm-Message-State: AHYfb5jb6JnYxyRnMVWLRxtjbIAL5Aon4ZOFer6Jzo/Ya9liU41I4YzD 92o/yqvP/YT/DsZH2VyiaA== X-Received: by 10.36.110.145 with SMTP id w139mr2719956itc.12.1503675875794; Fri, 25 Aug 2017 08:44:35 -0700 (PDT) Received: from pryzbyj (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id y62sm3153731ioi.70.2017.08.25.08.44.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 Aug 2017 08:44:35 -0700 (PDT) Received: by pryzbyj (Postfix, from userid 1000) id 7BD7E8023D2; Fri, 25 Aug 2017 10:44:34 -0500 (CDT) Date: Fri, 25 Aug 2017 10:44:34 -0500 From: Justin Pryzby To: Aniko Belim Cc: "pgsql-performance@postgresql.org" Subject: Re: Partitioned table - scans through every partitions Message-ID: <20170825154434.GC16287@telsasoft.com> References: <6EB8CBFC-49E5-4745-96D8-532EC912D039@spiceworks.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <6EB8CBFC-49E5-4745-96D8-532EC912D039@spiceworks.com> User-Agent: Mutt/1.5.23 (2014-03-12) 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 Fri, Aug 25, 2017 at 03:36:29PM +0000, Aniko Belim wrote: > Hi, > > We have an issue with one of our partitioned tables. It has a column with timestamp without time zone type, and we had to partition it daily. To do that, we created the following constraints like this example: > CHECK (to_char(impression_time, 'YYYYMMDD'::text) = '20170202'::text) > > > The problem we’re facing is no matter how we’re trying to select from it, it scans through every partitions. > It scans through every partitions. Shouldn’t it only scan the dfp_in_network_impressions.dfp_in_network_impressions_20170202 child table? Or we missing something? > Any advice/help would highly appreciated. https://www.postgresql.org/docs/9.6/static/ddl-partitioning.html#DDL-PARTITIONING-CAVEATS |The following caveats apply to constraint exclusion: | Constraint exclusion only works when the query's WHERE clause contains | constants (or externally supplied parameters). For example, a comparison | against a non-immutable function such as CURRENT_TIMESTAMP cannot be | optimized, since the planner cannot know which partition the function value | might fall into at run time. ... -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance