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 1mmudn-0008Oy-6J for pgsql-general@arkaria.postgresql.org; Tue, 16 Nov 2021 09:20:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mmudl-0001ci-Km for pgsql-general@arkaria.postgresql.org; Tue, 16 Nov 2021 09:20:33 +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 1mmudl-0001cY-6T for pgsql-general@lists.postgresql.org; Tue, 16 Nov 2021 09:20:33 +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 1mmudj-0007K8-6m for pgsql-general@lists.postgresql.org; Tue, 16 Nov 2021 09:20:32 +0000 Received: by mail-wr1-x433.google.com with SMTP id c4so36098246wrd.9 for ; Tue, 16 Nov 2021 01:20:30 -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:date:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=p2GFPfjCvOUbqsIv83AwdXMoZcLaFQC/5zXrJx4YTnE=; b=ou8JcnfjVh6Q27DyFOD0HveEVHuESPHU2BIGiaokn7cH7S+bDiEDMs/nvz1QThhOso /5UJdqCyllyS1UZXPDlNeoFCicFWLKXYkQgk6Z51g2O9u2lOmZ6bmfn3zwLiR5EecF+0 Gj4VvEPs97Xn/z6SbNqqIX/epoBJWalGx5o30ZKQ6aeG09M7dgyAdknnVkWZMmACbsBY KgDNlYSqXrfljF+4pxUdYy8GPJNV9asAxYkdXCMV/hV4a2hCLjxgXWBbJeXkwLuQEcSi Z2+57M3HPrNTPMEspbHIhRHlPrJdcVYx4tXsDXHbHp7DYXYMFtq4tmh0iw+aexHHrs09 MscA== 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:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=p2GFPfjCvOUbqsIv83AwdXMoZcLaFQC/5zXrJx4YTnE=; b=b/e/GQvYVeUaBsBewga5lrIfDA3syKlTwEfhklszUnPXrN61rVzRxfwFLkUSjFhl95 V9ZL/KUyX/G6bIfofJrPHXe0l8liBFHHWnqDV5i4iWzRjrGoarAR3fTVbFbtEkPve3sw tCQdMQYlimu6kJdTjWjyFVCErh6udTF6rKDx+BiiL3Yxnd4tq5N3og1ELdgQyFBZcxHy LN6o+QwQqCVq56Mpf9kBO4m8/S1wLST5eVkvcegxxgMlzJtL1yoxPctTdYL/QX/ZrX4N /mfhYynIF/u1ogysY+LV01C8DDYS6zOTZQbV8oxEpqwJfpIg3hAgfmHVxF7hIKpUYafK cHMg== X-Gm-Message-State: AOAM532KQdZCxequx9nDtKYg9sHn+tvMVbGBEnkbcm89X/650PrVQ9Rx 7ghUT5KYDiJAY47/DtG85+ef4Q== X-Google-Smtp-Source: ABdhPJy25QXvMOaeM/NpTHUmGk8Ydr4WgODGL0OvN3YnhDZWmxNX/AH7NwzAio7dbpo+/IWWccwvQg== X-Received: by 2002:adf:fd4c:: with SMTP id h12mr7269097wrs.429.1637054429627; Tue, 16 Nov 2021 01:20:29 -0800 (PST) Received: from localhost.localdomain ([88.116.133.170]) by smtp.gmail.com with ESMTPSA id h22sm1998462wmq.14.2021.11.16.01.20.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Nov 2021 01:20:29 -0800 (PST) Message-ID: <6e3e5cea05a44013d2dcbfddab96c3d9ad11238b.camel@cybertec.at> Subject: Re: historical log of data records From: Laurenz Albe To: Sanjay Minni , pgsql-general@lists.postgresql.org Date: Tue, 16 Nov 2021 10:20:28 +0100 In-Reply-To: References: 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 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. Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com