Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1faTYQ-0008EZ-Hn for pgsql-general@arkaria.postgresql.org; Tue, 03 Jul 2018 22:13:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1faTYN-00057F-Vv for pgsql-general@arkaria.postgresql.org; Tue, 03 Jul 2018 22:13:43 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1faTYN-000578-MJ for pgsql-general@lists.postgresql.org; Tue, 03 Jul 2018 22:13:43 +0000 Received: from mail-pg0-x236.google.com ([2607:f8b0:400e:c05::236]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1faTYK-0007kr-Pl for pgsql-general@lists.postgresql.org; Tue, 03 Jul 2018 22:13:43 +0000 Received: by mail-pg0-x236.google.com with SMTP id e11-v6so1568721pgq.0 for ; Tue, 03 Jul 2018 15:13:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=references:user-agent:from:to:cc:subject:in-reply-to:date :message-id:mime-version; bh=rO3QfuXVbvuazMi/G2GT4R3MkvEInM6ZA0fZPSdB5QE=; b=ZSo/dJ55ALll0XCGoctaJCjdsAUv70HDAyzCjj1vGotxerDmOaD9qv7WY6RP1FiSah SJE6tmOb2k6/aAGhPkjzf2G3c4E0T4vocnJnawThCyhR2Wz3giByp054RTZCkBcwVC4L 0sLSmTv1BYzG4P0H7YNjQnaDLc8E/FZTzOlGmJUvdGYCZi+viFxCx5dXMmtOlFRZDVdQ Zc883oRAkkfd1LQA4oDplcTNKXXcBmSqrSjDah9LA5cXViZsA3QD3MjU4ENHSPsF1tWb HFxnt5WkajEy3VZGoLGAjlrXHyp08otdzQtPx/XaRuA7vXZSrhWHmA17c9K6QwmNB0vu J/5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:references:user-agent:from:to:cc:subject :in-reply-to:date:message-id:mime-version; bh=rO3QfuXVbvuazMi/G2GT4R3MkvEInM6ZA0fZPSdB5QE=; b=nEo3KGDC0OeEMe4M6WJbdu59CCSxjMoyhrazW8d4l5ohu5DM2NewCTuPK5cx08KbOW 44YgnwT7uzZ30qhN0O9IMRLNIKUPycOscGrHa25rTA6wDmwTAugBX7QpIQGdzGWiFmlV O4XjFQXm3f/GHkGfltBIY+fxDQmZuz4ErxLb5lMeHZHFP2I4lZl0i9oPbU7PjTG9OnLU AuzS7H0tnYK6qBpj5phdrRvdfKc4B2xx2BHiuzDHpzFN9oScc9wOzFGIHUP79OQ8xDI1 W8NndHX0boTUPqTY6H0NAsFBQwiG4sS7Xf1sfzyVGM3+oA5MPh+btk2ywMZOBiF8WVUI 5KwQ== X-Gm-Message-State: APt69E2WdU4RmXNJgWdf3GXmgZqH9rVu4h9rSrTY2mcxZI4cypico2sd E0Wgu0OCXtWmALsT8K/HW8Yx9w+K X-Google-Smtp-Source: AAOMgpdnIRQfnL7Wn3+NK+SGNClJ1+Z1z4JKjppBHhUpfnzPw+oEcjowESTZOn4jxal1u7/UwqyN6g== X-Received: by 2002:a63:4e07:: with SMTP id c7-v6mr3529341pgb.293.1530656018002; Tue, 03 Jul 2018 15:13:38 -0700 (PDT) Received: from tim-desktop (2001-44b8-31f2-bb00-2ced-2e11-107f-c1f7.static.ipv6.internode.on.net. [2001:44b8:31f2:bb00:2ced:2e11:107f:c1f7]) by smtp.gmail.com with ESMTPSA id h16-v6sm5476301pfd.71.2018.07.03.15.13.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Jul 2018 15:13:37 -0700 (PDT) References: User-agent: mu4e 0.9.18; emacs 26.1 From: Tim Cross To: Rafal Pietrak Cc: pgsql-general@lists.postgresql.org Subject: Re: FK v.s unique indexes In-reply-to: Date: Wed, 04 Jul 2018 08:13:28 +1000 Message-ID: <87va9wvugn.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Rafal Pietrak writes: > > In particular, contrary to what the ERROR says, the target table *does > have* a "unique constraint matching given keys", admittedly only > partial. Yet, why should that matter at all? A unique index, partial or > not, always yield a single row, and that's all what matters for FK. Right? > Is that correct? I would have thought that if you have a multi-key unique index and you only provide values for some of the keys in the index, you would have no guarantee of a single row being returned. If this was true, then the additional keys are superfluous. Have you tried doing the same thing where the fk keys and remote unique index keys are equal in number? -- Tim Cross