Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tqHvt-002RBJ-TR for pgsql-general@arkaria.postgresql.org; Thu, 06 Mar 2025 20:35:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tqHvs-007uzK-Ji for pgsql-general@arkaria.postgresql.org; Thu, 06 Mar 2025 20:35:04 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tqHvs-007uyV-4z for pgsql-general@lists.postgresql.org; Thu, 06 Mar 2025 20:35:04 +0000 Received: from fhigh-b8-smtp.messagingengine.com ([202.12.124.159]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tqHvq-001MtC-08 for pgsql-general@postgresql.org; Thu, 06 Mar 2025 20:35:03 +0000 Received: from phl-compute-02.internal (phl-compute-02.phl.internal [10.202.2.42]) by mailfhigh.stl.internal (Postfix) with ESMTP id 054C325400E9; Thu, 6 Mar 2025 15:35:00 -0500 (EST) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-02.internal (MEProxy); Thu, 06 Mar 2025 15:35:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1741293300; x=1741379700; bh=rvLaC2m5G0DkQ2dMKJMgq8RCsxO0qEb5wcp5c6CeEdA=; b= hVOmmF2gx8xjeuLTa6P9hQ3wsj3J9KXFNlCue7LF7mfSVqhDvQbfLb44nXj4tF3n eGWw5xO1MUlX3/FarW5zTNfJ9BCfi/+rBaJAcqK+hRP4B+YivHzWztvMMxIj9cyd LsfX2noiWbgbqJwGLbzU8bJwNyRSafFmjbtPxxbrk5rki9QXdcyXaYE4DVrGVunH IzzI6QaGJmcEbSZrLpC6rvq4B7m63MSeGxcIXfzHi98onALdIY2i220B3ro3Ov2X rSTaouKbrjt+ObO2zADYnHR188jXwlvDg3TD+Y5GsxzjhsyxN/N69IW8+vykyw5G wkjpCWWVSVDzUYt8X6de2w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1741293300; x= 1741379700; bh=rvLaC2m5G0DkQ2dMKJMgq8RCsxO0qEb5wcp5c6CeEdA=; b=l GHgsHmdlFrNEDky91SvpFurk0Af9ntsHUkFbRQ8ugCfM/kzfXp0TL5X4npCJhP8i e/i3SVfPXIbCc+JwvQBth+nQkltJc0gADJaQlhIBv6MzeqZ2G65N8M8hS9fPRgZt yr3gdnozsd+0XxZeTcHmypXNXKVT2TDS980mTZpftLqfyVeoCizNmz+ByVpCoRNX Emuz+Mh7mjC5f3cIAEkl5QTtKCeO7ahksaj6WEgDwLq/EH0lLnbHW0chZxooD41k PAQlMGf7k4vUV83ctDd4y3OMO4fCbqFbcCfvRWkNZ4vy8EvwjgBbDXPzCeqvcZII XXkBEj73Z1xvbdGVUYMow== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddutdekjedvucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggv pdfurfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpefkff ggfgfuvfhfvefhjggtgfesthekredttddvjeenucfhrhhomheptegurhhirghnucfmlhgr vhgvrhcuoegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhmqeenucggtf frrghtthgvrhhnpedtgeeuheevfeetkeehkeehfefftedtgfdtuddujeeikefhffekudek tdffieffkeenucffohhmrghinhepphhoshhtghhrvghsqhhlrdhorhhgpdgprghmrgiioh hnrdgtohhmpdgrmhgriihonhdrtghomhenucevlhhushhtvghrufhiiigvpedtnecurfgr rhgrmhepmhgrihhlfhhrohhmpegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrd gtohhmpdhnsggprhgtphhtthhopedvpdhmohguvgepshhmthhpohhuthdprhgtphhtthho pehmrghrkhgsrhgrugihjhhusehouhhtlhhoohhkrdgtohhmpdhrtghpthhtohepphhgsh hqlhdqghgvnhgvrhgrlhesphhoshhtghhrvghsqhhlrdhorhhg X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 6 Mar 2025 15:35:00 -0500 (EST) Message-ID: <75b33741-ee99-4524-b63a-edad21c1266d@aklaver.com> Date: Thu, 6 Mar 2025 12:34:59 -0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Duplicate Key Values To: mark bradley References: <36356aa1-1a5c-44af-a1c0-f190249812ca@aklaver.com> <6aee94f9-d421-4622-bccc-bdac37969be0@aklaver.com> Content-Language: en-US Cc: pgsql-general From: Adrian Klaver In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 3/6/25 12:06, mark bradley wrote: My mistake I forgot to Cc list on my previous post, which was: That would be an issue and also would mean it is not a PK. In psql do: \d dataset and show the results as text in your reply. Ccing list The below shows there is an index("dataset_pkey") on node_id. Note, reindexing will take a lock on the table that prevents changing data while the operation is running. See the below for more information: https://www.postgresql.org/docs/current/sql-reindex.html If the table is not to big and you can interrupt access to it then the simplest command to run would be: REINDEX TABLE dataset; > Universal Metadata Schema=# \d dataset >                                  Table "public.dataset" >           Column           |           Type            | Collation | > Nullable | Defau > lt > ---------------------------+---------------------------+-----------+----------+------ > --- >  node_id                   | integer                   |           | > not null | >  dataset_name              | character varying(25)     |           | > not null | >  notes                     | text                      |           | >        | >  dataset_type              | database_type             |           | > not null | >  dataset_maturity          | database_maturity_type    |           | > not null | >  disposition               | disposition_type          |           | > not null | >  start_date                | date                      |           | >        | >  end_date                  | date                      |           | >        | >  most_recent_update        | date                      |           | >        | >  update_periodicity        | interval                  |           | >        | >  system_of_record          | text                      |           | >        | >  point_of_contact          | integer                   |           | > not null | >  dataset_url               | text                      |           | >        | >  classification_level      | classification_level_type |           | > not null | >  physical_location         | text                      |           | >        | >  quality_control           | yes_no_type               |           | > not null | >  dataset_documentation_url | text                      |           | > not null | >  description               | text                      |           | >        | >  node_type                 | node_type                 |           | >        | >  dummy                     | integer                   |           | >        | > Indexes: >     "dataset_pkey" PRIMARY KEY, btree (node_id) > Foreign-key constraints: >     "node_id" FOREIGN KEY (node_id) REFERENCES node(node_id) NOT VALID >     "poc" FOREIGN KEY (point_of_contact) REFERENCES poc(poc_id) NOT VALID > Referenced by: >     TABLE "dataset_table" CONSTRAINT "dataset" FOREIGN KEY (node_id) > REFERENCES datas > et(node_id) NOT VALID >     TABLE "dataset_subject" CONSTRAINT "dataset_subject_node_id_fkey" > FOREIGN KEY (no > de_id) REFERENCES dataset(node_id) >     TABLE "system_dataset" CONSTRAINT "system_dataset_node_id_fkey" > FOREIGN KEY (node > _id) REFERENCES dataset(node_id) NOT VALID > Inherits: node > > > Best regards, > Mark Brady > _amazon.com/author/markjbrady _ > ------------------------------------------------------------------------ > *From:* Adrian Klaver > *Sent:* Thursday, March 6, 2025 3:03 PM > *To:* mark bradley > *Subject:* Re: Duplicate Key Values > On 3/6/25 10:51, mark bradley wrote: > Reply to list alos. > Ccing list. > >> Looks like there is no index on node_id at the moment > > That would be an issue and also would mean it is not a PK. > > In psql  do: > > \d dataset > > and show the results as text in your reply. > >> >> >> Mark Brady, Ph.D. >> Deputy Chief Data Officer, TRMC >> _amazon.com/author/markjbrady >_ >> ------------------------------------------------------------------------ >> *From:* Adrian Klaver >> *Sent:* Thursday, March 6, 2025 1:22 PM >> *To:* mark bradley ; Ron Johnson >> ; pgsql-general >> *Subject:* Re: Duplicate Key Values >> On 3/6/25 10:11, mark bradley wrote: >>> Here is the table definition: >>> >>> >>> And here is the error message I get when I try to delete a duplicate: >> >> Please answer the following: >> >> 1) Did you not see duplicates with the old version of pgAdmin4? >> >> 2) What do you see if you use psql? >> >> 3) Did you upgrade/move the Postgres server or the underlying OS? >> >> 4) Have you tried reindexing the node_id field? >> >>> >>> >>> Mark Brady, >>> _amazon.com/author/markjbrady > >>_ >>> ------------------------------------------------------------------------ >> >> -- >> Adrian Klaver >> adrian.klaver@aklaver.com >> > > -- > Adrian Klaver > adrian.klaver@aklaver.com > -- Adrian Klaver adrian.klaver@aklaver.com