Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1ewBln-00032U-Ef for pgsql-general@arkaria.postgresql.org; Wed, 14 Mar 2018 19:09:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ewBlm-000162-D9 for pgsql-general@arkaria.postgresql.org; Wed, 14 Mar 2018 19:09:02 +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.89) (envelope-from ) id 1ewBlm-00015t-27 for pgsql-general@lists.postgresql.org; Wed, 14 Mar 2018 19:09:02 +0000 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ewBlj-0006Wf-Lo for pgsql-general@lists.postgresql.org; Wed, 14 Mar 2018 19:09:00 +0000 Received: by mail-pf0-x241.google.com with SMTP id f80so1816831pfa.8 for ; Wed, 14 Mar 2018 12:08:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=illuminatedcomputing-com.20150623.gappssmtp.com; s=20150623; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=bOI31hB2TlP789ye9vQN0lvifYaWSJdtRcMWufKhMfg=; b=qyRbGzBgcVUVpTMugAy+IP5o928RB8VW+sKTTKD4ypRjWxF+3XzGOj24sA6wrqtW6s 2ADf7LAIrFlUdtubs3qHlTjUpQ+ioMYtoQKsxBeENswNpVh/+OBL95mVWdZsB+NH5SQJ g4dizCbD4x46BSoZG4FyBx6mnldMlyOGZIha714ZnEUaGVJGc0yY+/09Te2aVSyBlk9w /Mfv6zQL/yuVBnZmbOwxWqZN/WP1EqHTICjtwKubuVGvE8AjsCU345l+7CBj1v0mVp+K /78+lfAxjP8/0LiqokamGrrizHxK+WbYgf9XHqzOV2JjhagChlrT3CjcEi6iOLJnEJRw /Xbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=bOI31hB2TlP789ye9vQN0lvifYaWSJdtRcMWufKhMfg=; b=Wm83muttkKeVsBtRoSEQlkTQIFu7ZlO0k9EeYHoQr0AHJI8fiKjCJUmC10C+QwzclJ pqVyn5cVC7Bpq1lPqTlJ0GruuvxpZ4CQqnEXNycKXoH/0zGohyULh6nBaUSH5Sdakpin 0e2IKH2Zb4XUonuQLCG4dos807hqoPBn41jGXehxa3ypAvmpp53IjoKwUFJODblduyk4 /bV8DL4XO/f5a95DtGsNQf8t1BIbI5OTTxy23trIK+ilLu/xzATO+nh8mgaxq5Dr1tjP FpWqIVK3fEIUp1lZ1JgTDtiIx3my9sBIjOkEOYZSPqKjJmd50fbtACFuyy8/IwK8brFy IVMA== X-Gm-Message-State: AElRT7Fxt2ApVp3A/HuEaXNzx+nbkA1qG8nZg1yqmmJXihKYH9HPruLx GUoxjlVJFfa8Ju5lmWEmbng5ue4a X-Google-Smtp-Source: AG47ELs5KP8QJSWl7jIU7bD0GeNChPY7fc1Df9A/zCJWXtFi6+MB0rlMYaQBwHsrHrEgwlVbp9n8Vg== X-Received: by 10.101.97.139 with SMTP id c11mr4575689pgv.443.1521054537844; Wed, 14 Mar 2018 12:08:57 -0700 (PDT) Received: from [192.168.2.201] (static-50-53-109-254.bvtn.or.frontiernet.net. [50.53.109.254]) by smtp.googlemail.com with ESMTPSA id q66sm6509239pfi.95.2018.03.14.12.08.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Mar 2018 12:08:57 -0700 (PDT) Subject: Re: Primary key gist index? To: Tom Lane , pgsql-general@lists.postgresql.org References: <420e0752-1197-c1be-c50c-eba42f35ad99@illuminatedcomputing.com> <9545.1521053096@sss.pgh.pa.us> From: Paul Jungwirth Message-ID: Date: Wed, 14 Mar 2018 12:08:56 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <9545.1521053096@sss.pgh.pa.us> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 03/14/2018 11:44 AM, Tom Lane wrote:> Also, as you mention, extrapolating behavior that's not really equality > to situations like foreign keys gets pretty interesting pretty fast. > An exclusion constraint using && might ensure that no two values in the > column are identical, but it would not be enough to ensure that a proposed > FK row can't && with more than one PK row. So what then? This is (perhaps) a digression from the OP's question, but in temporal databases it is fine if the child record's as_of_time overlaps with multiple records from the parent table. In fact that would be pretty normal. What's required is that the child's as_of_time is completely covered by the "sum" of the as_of_times of the parent records with a matching ID. For example: houses id as_of_time appraisal 1 [2016-01-01, 2017-01-01) $200k 1 [2017-01-01, 2018-01-01) $230k rooms id as_of_time house_id 1 [2016-01-01, 2018-01-01) 1 If you had a "temporal foreign key" from rooms to houses, that example should be valid. I understand that's not possible today with normal foreign keys, and maybe it's too specific to be desirable as a general-purpose feature, but that's what the github extension I linked to tries to offer. -- Paul ~{:-) pj@illuminatedcomputing.com