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 1pQ9vv-0000Xp-Sm for pgsql-sql@arkaria.postgresql.org; Thu, 09 Feb 2023 16:38:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pQ9vu-0008Rm-Nw for pgsql-sql@arkaria.postgresql.org; Thu, 09 Feb 2023 16:38:02 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pQ9vu-0008PS-DL for pgsql-sql@lists.postgresql.org; Thu, 09 Feb 2023 16:38:02 +0000 Received: from premium22-2.web-hosting.com ([68.65.122.104]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pQ9vr-0004Aj-63 for pgsql-sql@lists.postgresql.org; Thu, 09 Feb 2023 16:38:01 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=misuse.org; s=default; h=Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=vvNIaK6+D1Bw7DWnjmLF76/GijO682Tm11IPVlPMZ/w=; b=PmPfa+xMJsGvxf7QdOdkmVzZjk vO6Sbjx+6tFPDq9vvmbAO0QYLqqqCKcqlrm5EtmrQVfmLHNTvB64DB9EkXsmt6XQC49WnSI6YqePu 2tZmIOMpcEdQD0lIt7rp4s6rxwTO7IG93DqSJSWGbQPp3f3lEEeHRJVdvuekTlDqa2m1JjNEtiAT1 F9XPTp6TC3EIbqrjxKdW+e1M8THiTnNygkL7bG9ZSvHHtMzsPrRNh11phlyTQ2zOH7QUOtkwJpJhh pL8wo2Mt27ElIuXJMYtc6UFFz4hd9Yd5xOLe0db4tHz2EYvORtqbk/xJ4KQmzWbCf2CYMtcyV5RxZ lJiPDCyg==; Received: from mail-yw1-f179.google.com ([209.85.128.179]:45815) by premium22.web-hosting.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.95) (envelope-from ) id 1pQ9vf-006kZe-R9 for pgsql-sql@lists.postgresql.org; Thu, 09 Feb 2023 11:37:52 -0500 Received: by mail-yw1-f179.google.com with SMTP id 00721157ae682-4c24993965eso32205907b3.12 for ; Thu, 09 Feb 2023 08:37:47 -0800 (PST) X-Gm-Message-State: AO0yUKWMT2OfqNM4ZQ5enVBjp3vZxLlSt4tIWU1CYt2fEt//FMa3qGAN czO0sMeTqSnzQGSD7U/uIxcBFdl5is9wVs8R58k= X-Google-Smtp-Source: AK7set+Tr5PIXfkcGErjL5AW7n2ry8zqx2UKiDJ1vmj6fHogEx8wXhqJ1okOfGJc3JYu5u1NK+vw1mplT0khWvCW+vo= X-Received: by 2002:a0d:d60d:0:b0:52e:c54d:1891 with SMTP id y13-20020a0dd60d000000b0052ec54d1891mr122714ywd.252.1675960666921; Thu, 09 Feb 2023 08:37:46 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Steve Midgley Date: Thu, 9 Feb 2023 08:37:35 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: How to ensure a log-entry is created based on state of data in other tables To: Andreas Joseph Krogh Cc: pgsql-sql@lists.postgresql.org Content-Type: multipart/alternative; boundary="00000000000035a45e05f44700e3" X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - premium22.web-hosting.com X-AntiAbuse: Original Domain - lists.postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - misuse.org X-Get-Message-Sender-Via: premium22.web-hosting.com: authenticated_id: science@misuse.org X-Authenticated-Sender: premium22.web-hosting.com: science@misuse.org X-Source: X-Source-Args: X-Source-Dir: X-From-Rewrite: unmodified, already matched List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000035a45e05f44700e3 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Feb 9, 2023 at 8:33 AM Andreas Joseph Krogh wrote: > P=C3=A5 torsdag 09. februar 2023 kl. 16:08:16, skrev Steve Midgley < > science@misuse.org>: > > [=E2=80=A6] >> >> >> > What is the time window required for "DONE" and "NOT_DONE" to be correct? > Do they need to be atomic (meaning the time window is effectively 0)? Or > can the system "notice" recent changes and keep track of done/not done > after-the-fact? If your time window is > 0, it seems like recurring > processes could be set up to track DONE / NOT_DONE? > > Another totally different way to think about this is to create a view tha= t > provides answers on DONE and NOT_DONE as computed values based on the > underlying state of the table at the time the view is queried? That would > seem to satisfy a time window of 0? > > Steve > > Yes, they need to be atomic. Either all are DONE and there *is* an entry > in activity_product_log for product_id, *or* there is no entry in > activity_product_log. > > > So, would the view table approach work? So DONE / NOT_DONE is simply calculated at the time that view is queried? It seems atomic to me, especially if the query to the table is made with the appropriate concurrency flags? --00000000000035a45e05f44700e3 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Thu, Feb 9, 2023 at 8:33 AM Andrea= s Joseph Krogh <andreas@visena.com= > wrote:
=
P=C3=A5 torsdag 09. februar 2023 kl. 16:08:16, skrev Steve Midgley <= ;science@misuse.org= >:

[=E2=80=A6]

=C2=A0

What is the time window required for "DONE" and &q= uot;NOT_DONE" to be correct? Do they need to be atomic (meaning the ti= me window is effectively 0)? Or can the system "notice" recent ch= anges and keep track of done/not done after-the-fact? If your time window i= s > 0, it seems like recurring processes could be set up to track DONE /= NOT_DONE?
=C2=A0
Another totally different way to thin= k about this is to create a view that provides answers on DONE and NOT_DONE= as computed values based on the underlying state of the table at the time = the view is queried? That would seem to satisfy a time window of 0?
=C2=A0
Steve=C2=A0

Yes, they = need to be atomic. Either all are DONE and there is an entry in activity_product_log for product_id, or there = is no entry in activity_product_log.

=C2=A0

So, would the view table approach work? So DONE / NOT_DONE is simp= ly calculated at the time that view is queried? It seems atomic to me, espe= cially if the query to the table is made with the appropriate concurrency f= lags?=C2=A0
--00000000000035a45e05f44700e3--