Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 215C51337B66 for ; Thu, 28 Oct 2010 16:25:30 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 65445-02 for ; Thu, 28 Oct 2010 19:25:22 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-yw0-f46.google.com (mail-yw0-f46.google.com [209.85.213.46]) by mail.postgresql.org (Postfix) with ESMTP id 5E6491337B64 for ; Thu, 28 Oct 2010 16:25:22 -0300 (ADT) Received: by ywk9 with SMTP id 9so1531239ywk.19 for ; Thu, 28 Oct 2010 12:25:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:subject:mime-version :content-type:from:in-reply-to:date:cc:content-transfer-encoding :message-id:references:to:x-mailer; bh=0//aOEz2lVcuDEBH6PB5i62Vzeng2C4bgeov/AamoFU=; b=j4upjdL+gn+fwLCFhyf8fHbaLt0LVXFiro3SBUX3pehkAXd9tVOiXxvs3hAxwVo7yK C15P2lVq0OPjBUMFCuydAfveZIK7rhTkPc/c6crpBEBWXEf2vnJENIrw8AA8Q9SFzJhj 6NGsEDXitKGQaIlsDE0l17D5brsqDDt7FZqJE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:mime-version:content-type:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to:x-mailer; b=NOQdhBHla0YMaM9czZNYsQ7d9sfPnu3yJTM61BhQD738dZCvSVSJtUskuG1dLEaVsi oScnxalyXl6kvCgBOWlOGJLA+q0EGO9VE5J7FZBqfSDVhktg3TBBx5mkid5h4bs5D1SR N6JwS9+cCoA0YbBzRGrHLCIryGt5AynKPoAwE= Received: by 10.151.109.21 with SMTP id l21mr20983577ybm.361.1288293921866; Thu, 28 Oct 2010 12:25:21 -0700 (PDT) Received: from [192.168.1.106] (74-95-195-236-SFBA.hfc.comcastbusiness.net [74.95.195.236]) by mx.google.com with ESMTPS id z16sm1034956ybm.16.2010.10.28.12.25.19 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 28 Oct 2010 12:25:20 -0700 (PDT) Subject: Re: partitioning question 1 Mime-Version: 1.0 (Apple Message framework v1081) Content-Type: text/plain; charset=us-ascii From: Ben In-Reply-To: <1288291814.22359.31.camel@jd-desktop> Date: Thu, 28 Oct 2010 12:25:16 -0700 Cc: pgsql-performance@postgresql.org Content-Transfer-Encoding: quoted-printable Message-Id: <4486C61F-DC08-4DE4-8AF9-245FA60B0310@gmail.com> References: <1288287092.22359.23.camel@jd-desktop> <1288291814.22359.31.camel@jd-desktop> To: jd@commandprompt.com X-Mailer: Apple Mail (2.1081) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001 X-Spam-Level: X-Archive-Number: 201010/557 X-Sequence-Number: 40975 On Oct 28, 2010, at 11:50 AM, Joshua D. Drake wrote: >>> Yes the constraints have to be static. Not sure about the operator >>> question honestly. >>=20 >> this seems to severely restrict their usefulness -- our queries are = data warehouse analytical -type queries, so the constraints are usually = data-driven (come from joining against other tables.) >=20 > Well it does and it doesn't. Keep in mind that the constraint can be: >=20 > date >=3D '2010-10-01" and date <=3D '2010-10-31' >=20 > What it can't be is something that contains date_part() or extract() = (as > an example)=20 i think we are talking about two different things here: the constraints = on the table, and the where-clause constraints in a query which may or = may not trigger constraint exclusion. i understand that table = constraints have to be constants -- it doesn't make much sense = otherwise. what i am wondering about is, will constraint exclusion be = triggered for queries where the column that is being partitioned on is = being constrained things that are not static constants, for instance, in = a join. (i'm pretty sure the answer is no, because i think constraint = exclusion happens before real query planning.) a concrete example : create table foo (i integer not null, j float not null); create table foo_1 (check ( i >=3D 0 and i < 10) ) inherits (foo); create table foo_2 (check ( i >=3D 10 and i < 20) ) inherits (foo); create table foo_3 (check ( i >=3D 20 and i < 30) ) inherits (foo); etc.. create table bar (i integer not null, k float not null); my understanding is that a query like select * from foo, bar using (i); can't use constraint exclusion, even if the histogram of i-values on = table bar says they only live in the range 0-9, and so the query will = touch all of the tables. i think this is not favorable compared to a = single foo table with a well-maintained btree index on i. >>>> is my intuition completely off on this? >>>=20 >>> You may actually want to look into expression indexes, not clustered >>> ones. >=20 > Take a look at the docs: >=20 > = http://www.postgresql.org/docs/8.4/interactive/indexes-expressional.html >=20 > It "could" be considered partitioning without breaking up the table, > just the indexes. do you mean partial indexes? i have to confess to not understanding how = this is relevant -- how could partial indexes give any advantage over a = full clustered index? b=20=