Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1jF33y-00042X-JD for pgsql-general@arkaria.postgresql.org; Thu, 19 Mar 2020 21:50:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jF33x-0006tx-BU for pgsql-general@arkaria.postgresql.org; Thu, 19 Mar 2020 21:50:49 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1jF33w-0006tq-QE for pgsql-general@lists.postgresql.org; Thu, 19 Mar 2020 21:50:49 +0000 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jF33q-0000in-9X for pgsql-general@lists.postgresql.org; Thu, 19 Mar 2020 21:50:47 +0000 Received: by mail-pf1-x442.google.com with SMTP id c19so2119353pfo.13 for ; Thu, 19 Mar 2020 14:50:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=RQjedk+kYAN+fyEs/MCUuyLUm80SjzcftFTwzgOpir4=; b=ggE2lWWjf7zzZFYaZ1xwPCoW6jWiKgPFCJ6ZHSYa8QTb3gcYiqlROzH+vXrzQEbsr8 GMsvN5VsuK9YWQ1Ze9YD5dg4m3l0PGvkUC9pp8z7njCoEiVSMf2tTcnzwuCH639+O8QY ARHAuyQuwMPpCqOKYTJR5L5AECSzAtKxI8UsnNQGTF2qsBTeHcNMKEWM4QtNcdy8SQIW 6LRpJvBeY6heewP5WKUjOnt8dKh+/YkTq9jcBMhIhRXAtYd5QVVaRzUroMEwZWJBfDS3 gMio3FOg/cbF4fN/VbcKN/K903uRffpIje9adlTb6W1OI4YNoVElsp8DWDfb68qhj4Zz yk/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=RQjedk+kYAN+fyEs/MCUuyLUm80SjzcftFTwzgOpir4=; b=es2AP1eeR3AR4ybff/nD7mDMbkTSFXDPZHw4FFl2OQPXwtxwaD5NY0OqI8jBn24Pkb Btq9kpaVvP9FYOL/TW4xS+pZw/sYsLIco+RQXuwWMKhzYlMVN5B5k07v74VN8JRCQpLh uaY4FRTHcYfM3davC0Iq+vvJMDNVxX9iY4T+bkFQrwMbcVC5TX2u8jvvld9fvmu5zJHl OsNsK5/y0zClNd6yFYwSS0r2LlDA9hPgGz5qLnaLPEbOEI8GMc1VT3lABS6AB6MdAtlG BvQamscbFh2H5VnV7JhhtAVQe/S9v75AL8kKWcPpcslk8I2NlBn38VYbjpFcd17X+TOj IT6g== X-Gm-Message-State: ANhLgQ25W8bnzzuO46lxfkKT9bMA2dfkQvlMz+ITcq6mIS3EAGLu9aAD lMHZViTAB0ZoGnDcuIO49eE= X-Google-Smtp-Source: ADFU+vsTVA4L9USvtxZGuQxcmyPKuf2RUSEbQgyo2G+lh0Qin1f1lqTAnqA52l6y2hy4xOi3u2FjYg== X-Received: by 2002:a62:fc07:: with SMTP id e7mr6330576pfh.299.1584654640755; Thu, 19 Mar 2020 14:50:40 -0700 (PDT) Received: from [192.168.1.108] (c-73-63-59-118.hsd1.ut.comcast.net. [73.63.59.118]) by smtp.gmail.com with ESMTPSA id z125sm3470497pfz.187.2020.03.19.14.50.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Mar 2020 14:50:40 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.0 \(3608.60.0.2.5\)) Subject: Re: Could postgres12 support millions of sequences? (like 10 million) From: Rob Sargent In-Reply-To: Date: Thu, 19 Mar 2020 15:50:38 -0600 Cc: "pgsql-generallists.postgresql.org" Content-Transfer-Encoding: quoted-printable Message-Id: References: To: pabloa98 X-Mailer: Apple Mail (2.3608.60.0.2.5) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk > On Mar 19, 2020, at 3:36 PM, pabloa98 wrote: >=20 > Hello, >=20 > My schema requires a counter for each combination of 2 values. = Something like: >=20 > CREATE TABLE counter( > group INT NOT NULL, > element INT NOT NULL, > seq_number INT NOT NULL default 0, > CONSTRAINT PRIMARY KEY (group, element) > ); >=20 > For each entry in counter, aka for each (group, element) pair, the = model requires a seq_number. >=20 > If I use a table "counter", I could still have counter collisions = between 2 transactions. I need truly sequence behavior. Is that possible = by using a table like "counter" table, where the counter could be = increased out of the transaction so it performs as a sequence without = having race conditions between concurrent transactions? >=20 > The other option is to create sequences for each new pair of (group, = element) using triggers. There are millions of pairs. So this approach = will generate millions of sequences. >=20 > How a PostgreSQL database would behave having millions of sequences in = a schema? Would it degrade its performance? Is there any negative = impact? >=20 > Regards >=20 > Pablo >=20 To clarify, are you hoping for consecutive numbers as the each row is = added to the table, i.e. =E2=80=9Cserial=E2=80=9D? What is the intension of =E2=80=9Cseq_number=E2=80=9D? >=20 >=20