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 1ewBCl-0000vx-Vo for pgsql-general@arkaria.postgresql.org; Wed, 14 Mar 2018 18:32:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ewBCk-0005Sx-DU for pgsql-general@arkaria.postgresql.org; Wed, 14 Mar 2018 18:32:50 +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 1ewB98-0000Ov-G4 for pgsql-general@lists.postgresql.org; Wed, 14 Mar 2018 18:29:06 +0000 Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ewB94-0005U8-HD for pgsql-general@lists.postgresql.org; Wed, 14 Mar 2018 18:29:04 +0000 Received: by mail-pg0-x244.google.com with SMTP id m15so1736409pgc.1 for ; Wed, 14 Mar 2018 11:29:01 -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=aFN9tNN+FQY8Piv35GdTc23W63p6GvlPqVDAJI+xEVg=; b=Ow2Ij9bwBLkbqubT/3vUhCNfJefNGmuf6slMVg6qET+Lxp9UFlKNdO7aFVTCMvg7v0 nE15AHj7K6qJoTZsJqoKlsITZzIN9wnAcjc6ypWieUECwXLDjuUbcGKF4KUp0jRFoCDY xY66y+Zmb5HuRokmuHQyLl3wU2KI7mmESjnmAIVbnie++xKrS+nDTqf5Kh7fdW4XtEDP 1YPi9A1EmEt6/TmwaLkj8j5rvoggRs6Kb3dffutM5EkUSRWxUIrSAO84Y3t6u6tgEl/X wyq8IDRneGBleWdMOm1Hb24QziFwCO7yvhwwhJR6yWyKbhAyY9LFd2qVYtZHDVwjNwZt f1VA== 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=aFN9tNN+FQY8Piv35GdTc23W63p6GvlPqVDAJI+xEVg=; b=L5l3092o/aTDchSvVPw1jnMe4YqJEJ0U5r3x3hsWPPBs6EGrTmTRyuD1gVgZbqoJXt YUTLps7AHC0Z+0IdtOqP9cITyURs6hHEkzIoBQBMkh6bT0UCwos+6uRs9/RkEF1je9DD TKaEOLX+x21EEp++3+iGgWpAPK7x8jIx22uZIAkUMORsVT0WlHnWRXADKWEzYa4Gdwqw zPeDFpwgNnz7vLelkg74haV7xB4XZkDX2vRxXhXKinCtKqb8B4P9OvLOgg/DKze52PdP 24fJvDKp8ykPeGsDRyUFt8n3/pdd/y0OX5TfWjQ9ickiS9rGvUia+dWasLUmjgGHRj/f 9nCQ== X-Gm-Message-State: AElRT7F/g9Uy7jfIv7Xek3cAPx4CCt+EqojToornD9+qnEtWlwmwnUMj 8lWRvhxd+B/GKGVoncLJTMk9YGiO X-Google-Smtp-Source: AG47ELuXufO/06iuwUoFsvaPwxHaU5SVUJTAPzeE9/27kIKxOEWuJhxLXya54ulYYXolvHGQ4z+nJw== X-Received: by 10.99.109.136 with SMTP id i130mr4537345pgc.380.1521052140674; Wed, 14 Mar 2018 11:29:00 -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 z67sm671964pgb.69.2018.03.14.11.28.59 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Mar 2018 11:28:59 -0700 (PDT) Subject: Re: Primary key gist index? To: pgsql-general@lists.postgresql.org References: From: Paul Jungwirth Message-ID: <420e0752-1197-c1be-c50c-eba42f35ad99@illuminatedcomputing.com> Date: Wed, 14 Mar 2018 11:28:59 -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: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 03/14/2018 06:19 AM, Jeremy Finzel wrote: > Hello!  From all that I can tell, it is not possible using a btree_gist > index as a primary key.  If so, why not?  I have a table with this gist > index which truly ought to be its primary key.  as_of_date is of range > date type: > > EXCLUDE USING gist (id WITH =, as_of_date WITH &&) I'm curious why you need a primary key on this table, especially if the exclusion constraint is already preventing duplicate/overlapping records? Technically I think an exclusion constraint (or at least this one) fulfills the formal requirements of a primary key (is unique, isn't null), but maybe there are other primary-key duties it doesn't meet, like defining foreign keys that reference it. I've been on-and-off building an extension for temporal foreign keys at [1]. That is pretty new, but perhaps it will be useful/interesting to you. And if you have any feedback, I'd love to hear it! But anyway, maybe if you shared why the table needs a real PRIMARY KEY, people here can suggest something. [1] https://github.com/pjungwir/time_for_keys Yours, -- Paul ~{:-) pj@illuminatedcomputing.com