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 1sI13c-00CCT5-RE for pgsql-general@arkaria.postgresql.org; Fri, 14 Jun 2024 07:09:08 +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 1sI13a-00EOKW-Ec for pgsql-general@arkaria.postgresql.org; Fri, 14 Jun 2024 07:09:07 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sI13a-00EOKN-3v for pgsql-general@lists.postgresql.org; Fri, 14 Jun 2024 07:09:07 +0000 Received: from mail-ed1-x52e.google.com ([2a00:1450:4864:20::52e]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sI13Y-001anE-KP for pgsql-general@lists.postgresql.org; Fri, 14 Jun 2024 07:09:06 +0000 Received: by mail-ed1-x52e.google.com with SMTP id 4fb4d7f45d1cf-57a30dbdb7fso2649799a12.3 for ; Fri, 14 Jun 2024 00:09:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718348943; x=1718953743; darn=lists.postgresql.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=6BZTMZ20AOVGh4uv97E+UAeCPTK3IW5DDyUyEsjm3LQ=; b=nBabd+IF4GjndSTegIrI94J+MFpYwbhJpX/8B96mJDLdSF5sOQv1KNa5m4k9RquPRq p7MKnYJ1fCQ0G77OywE5tg786Vi/oj7UovNWE5ZnxYHG5OtheDhciOCSj2o4UK/Mcv+2 YjkykM9L6JhQyVkR/RW2rETNd7iTDBhMWAX2rmmC7QJpFS0l/eduSjUnkijciHSK2eT7 nGP9FvRqw7OZJ4UCDJVcKG5/1B9zZCby0Nzk4w+ZP/qG9NKvI1aSJ3F/MnmD9UoLbr92 DJSh10G4hAC/0+ZaGBuh1QxQIdUpWZK0wKtHm6Fab+dYaAeQrz46/S4OF2h1bQRYENfk 40Rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718348943; x=1718953743; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6BZTMZ20AOVGh4uv97E+UAeCPTK3IW5DDyUyEsjm3LQ=; b=DMK7UR9LGvhc1mm3rTC+8IgQUcXXPjg60PF2HZUPvAFvYSJtD93yy0DyTy1PhTGEZY K5bgZYpOIGPdpxR5G5pPdRAQaxXVHhPSBm0KMPSe3zEXEI4V/Ys/DfrccIh0bvfwkI9b fekkL5MMUCSxFRLGa6QSOWUm/g/oGlZfzaq8ovg5kfu+iE1O/GaUM+mboyn2xK917rNp YGI5UDAgUD6Pqan507SaKuowNnxR9oOpPZFi2tYtn+/9QKcRMUBIWyYhXFtamTjKB67d 8FKq/3RPrbT0tXtzyp2gt+LhJsVnBwWIvibMpr1oijuT5o/yVcpHcnS2EvIjuaEy6s4N hXpQ== X-Gm-Message-State: AOJu0YyLZla4spxebXq1CRoPWArRrvbF0lr1BenPus8zQ4Bg/cGc9ta0 TRG8ZZPGn+OwsCywWUOm33lsxTp1T6bkQnGfFmydFIH1wQcgR+zs X-Google-Smtp-Source: AGHT+IHVh/pdlgsuohr/gN7fZE3oigiBt8EqZPnsGKn/XHgYHvVYIe1oMTVEUZtx/QbJuQsA5IBWEQ== X-Received: by 2002:a17:906:85b:b0:a6e:f533:ce28 with SMTP id a640c23a62f3a-a6f60cf1db5mr128748566b.12.1718348942582; Fri, 14 Jun 2024 00:09:02 -0700 (PDT) Received: from smtpclient.apple ([188.212.112.125]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6f56f41ad3sm150191966b.181.2024.06.14.00.09.01 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Jun 2024 00:09:01 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.600.62\)) Subject: Re: Reset sequence to current maximum value of rows From: Alban Hertroys In-Reply-To: Date: Fri, 14 Jun 2024 09:08:51 +0200 Cc: pgsql-general Content-Transfer-Encoding: quoted-printable Message-Id: References: <387fa6c2-5de-f24-d522-46282597703@appl-ecosys.com> <1b139d9a-b95f-f7c8-52fb-9d7442c69ad9@appl-ecosys.com> <97d69b9-48de-3bd4-95d-df5614ff44a@appl-ecosys.com> <4f319e27-0e54-40dd-888f-1e4c856a1b02@aklaver.com> To: Rich Shepard X-Mailer: Apple Mail (2.3774.600.62) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > company_nbr | company_name = -------------+------------------------------------------------- > 1 | Markowitz Herbold PC > 2 | Markowitz Herbold PC > 3 | Markowitz Herbold PC > 4 | Markowitz Herbold PC > 5 | Markowitz Herbold PC > 6 | Markowitz Herbold PC > 7 | Markowitz Herbold PC > 8 | Markowitz Herbold PC > 9 | Markowitz Herbold PC > 10 | Markowitz Herbold PC > 11 | Markowitz Herbold PC > 12 | Markowitz Herbold PC > 13 | Markowitz Herbold PC > 14 | Markowitz Herbold PC > 15 | Markowitz Herbold PC > 16 | Markowitz Herbold PC > 17 | Markowitz Herbold PC > 18 | Markowitz Herbold PC > 19 | Markowitz Herbold PC > 20 | Markowitz Herbold PC > 22 | Markowitz Herbold PC > 23 | Markowitz Herbold PC > --More-- Did those rows contain these values in some earlier transaction in your = data-entry process perhaps? I=E2=80=99m thinking that perhaps you = overwrote them in a later transaction with the correct values for the = names, but forgot to commit that transaction? It=E2=80=99s either that, or you did run an UPDATE statement against = those rows without specifying a WHERE-clause, as others already = suggested as a likely cause. I think we can rule out the possibility of index corruption (a very rare = occurrence, usually caused by factors external to PG) for your case. A = data-set this limited would most likely result in an execution plan = using a sequential scan instead of an index scan (an EXPLAIN ANALYZE of = above select statement would show proof). > It might be quicker for me to restore the entire database from that = backup > and then insert all new table rows since I have saved all the scripts. If you end up in the same situation again after doing that, then you = know at least it=E2=80=99s repeatable and can analyse how you got there. Alban Hertroys -- If you can't see the forest for the trees, cut the trees and you'll find there is no forest.