Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mn0bq-00066I-Gm for pgsql-general@arkaria.postgresql.org; Tue, 16 Nov 2021 15:42:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mn0bn-0003qM-NC for pgsql-general@arkaria.postgresql.org; Tue, 16 Nov 2021 15:42:55 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mn0bn-0003qD-9E for pgsql-general@lists.postgresql.org; Tue, 16 Nov 2021 15:42:55 +0000 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mn0bg-0005JO-3Q for pgsql-general@lists.postgresql.org; Tue, 16 Nov 2021 15:42:54 +0000 Received: by mail-wr1-x433.google.com with SMTP id u18so38440040wrg.5 for ; Tue, 16 Nov 2021 07:42:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20210112.gappssmtp.com; s=20210112; h=message-id:subject:from:to:cc:date:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=Yv0VKVkJD//suw3lBQji8Y5BRjwe60dmTwhAe9xNC+U=; b=Sx6ZIO7+WPlorkzxObwVlhaWvw3BrXOOrE5RCx2NKb9bFiGAywlGFluuJ1COPTaS7o flBZH9z3Qn+rlz/fEmz9R8F9pi3y9vZGrtoEXJ+xGhbpRC+wsTY0gfKi/SeSmeyEkqJo GxLbJBaHBVY52/UNmVqhYd7LhUpc4p7kyPmNObE62qT9ldL/jkv0JXcVzAWuTc8xbU12 E0rzr+W/xOq8c7FenroO/nZZb9YNSLt1XxTwGzmIyiC8RAqMwcbBskKXspSWlt7D2DHA haLtq6epmrdYECZ+LQvZi6epMHbIMA8eok/eUf0nUTU6PNVpi+Qmkvm0YX4sg3FyHyM5 wkoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=Yv0VKVkJD//suw3lBQji8Y5BRjwe60dmTwhAe9xNC+U=; b=CDrf661iORmLe1Z6hQ5j5Br2P3crwMlR7ylhUfj/8PJVfUVLRuVJQFBW7yEg1BZ2HH l1s00cT5Qd4fTyVQm3uc0LS0FJH+0nauvT0HeCjMm7hn1OcZ0ahnDTXZKtkD0fgBAdPc XRFd0lyzu2S6rrg3k63cAqLkpckGdLxheNuA2gdH+wTldgDUTf8CUeJr8i1B6Hszg15v F7c4owaHc29NUnAxgMiNRl3GX514bXMfU6MXSaSPonsdhzFvw8lNBdfcbK9dSZ6RpWpo N5hM+bDm21MzhCIw890ALUisQLJ+ryIedYWwrIHxRWFA0EPw1h9i1S9OQ9xpr8cYKrx+ zM8g== X-Gm-Message-State: AOAM533d+/nN6q68mmH6yOEmxRnZEF4VOwSje8bTS+HnxRpXI4vjGS5A VlfCbdr0oGzl60xRz6dJ4RBPaw== X-Google-Smtp-Source: ABdhPJyLJwxHYd0xmmOizA5RiU/nUF86sasFoMACmE3UBZZJFkBE1sHUnBh437ZsaLvJa3kTEv61vw== X-Received: by 2002:a5d:6d0c:: with SMTP id e12mr10932191wrq.94.1637077366989; Tue, 16 Nov 2021 07:42:46 -0800 (PST) Received: from localhost.localdomain ([88.116.133.170]) by smtp.gmail.com with ESMTPSA id n13sm18043727wrt.44.2021.11.16.07.42.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Nov 2021 07:42:46 -0800 (PST) Message-ID: Subject: Re: historical log of data records From: Laurenz Albe To: Sanjay Minni Cc: pgsql-general@lists.postgresql.org Date: Tue, 16 Nov 2021 16:42:46 +0100 In-Reply-To: References: <6e3e5cea05a44013d2dcbfddab96c3d9ad11238b.camel@cybertec.at> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.40.4 (3.40.4-2.fc34) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, 2021-11-16 at 15:24 +0530, Sanjay Minni wrote: > > On Tue, 16 Nov 2021 at 14:50, Laurenz Albe wrote: > > On Tue, 2021-11-16 at 13:56 +0530, Sanjay Minni wrote: > > > I need to keep a copy of old data as the rows are changed.  > > > > > > For a general RDBMS I could think of keeping all the data in the same table with a flag > > > to indicate older copies of updated /  deleted rows or keep a parallel table and copy > > > these rows into the parallel data under program / trigger control. Each has its pros and cons.  > > > > > > In Postgres would i have to follow the same methods or are there any features / packages available ? > > > > Yes, I would use one of these methods. > > > > The only feature I can think of that may help is partitioning: if you have one partition > > for the current data and one for the deleted data, then updating the flag would > > automatically move the row between partitions, so you don't need a trigger. > > Are you referring to Table Partitioning ? > https://www.postgresql.org/docs/14/ddl-partitioning.html Yes, exactly. Yours, Laurenz Albe