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 1sYqaA-00EUDY-3X for pgsql-general@arkaria.postgresql.org; Tue, 30 Jul 2024 17:24:17 +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 1sYqa8-00C0C5-Lg for pgsql-general@arkaria.postgresql.org; Tue, 30 Jul 2024 17:24:16 +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 1sYqa8-00C0Bw-Al for pgsql-general@lists.postgresql.org; Tue, 30 Jul 2024 17:24:16 +0000 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sYqa1-002IFk-T0 for pgsql-general@lists.postgresql.org; Tue, 30 Jul 2024 17:24:15 +0000 Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-a7d2a9a23d9so538604366b.3 for ; Tue, 30 Jul 2024 10:24:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20230601.gappssmtp.com; s=20230601; t=1722360248; x=1722965048; darn=lists.postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:from:to:cc:subject:date :message-id:reply-to; bh=Fo+3tjr6YtjeyOgLrCc7O8JaeDJUBe4+RWeZ2TbuAbk=; b=XM8scXUAYYD/kfzaSefW+c0TwtC+ve1Qs9KamXF+W5SrRqE+ISecvWNFdZ/S3P77Fw 9APyO+JkJuzc4mPpBolKn6ojxRgmbVXc19q4BHM4nkDyq1RwB0UBitPoHAvg8KCFk0OD GhDggVpTMQbvd7GV3SNdRGJHp9HdLNEazzYfXLkbSSvDREQ51cdhkpkkN2nyk7HIlXEM jzApnZlbFkkpOAKbh+hsHbqlXRBASPl3YUmjAZbQrcl+EqgCye6XfXeYacOw4jBviUSi 37Boa3qJetu4FnQvqVqD2QndOHA0UJAVFAg0aiR+apgcPkbHjeThpc6bhg/bwBd/BvKf H8+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722360248; x=1722965048; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Fo+3tjr6YtjeyOgLrCc7O8JaeDJUBe4+RWeZ2TbuAbk=; b=LLz7l4g2CsVlNQ7uCUB6NHgasv6sPBpdhzflg6N4L8AkLL2e5PyiI5BPY3dZ7BuPyt dzrJ4q0U77+NGSVVl0N0n/xCZdKS0izqiec6aVJlmYcDTRxfF26xyGp9OjGdF9Pz0Qix fvGiEmrTRq5omepl8UZqQBmKpnQnsbHyEfQGZ/96U8NxnTMuMm74wGWFqAmQzrzAID+1 U09iFYuJ2yLQR3NcQbzagPKFLQAUGtvNyTCIeLoNGFyp59T4rZxQr2Ooya15l9U57PLn 6OMyUOlL3KgIZt6X6G/jKmTavKLA/4gRh6zTSPTPs/ujvzAutC4NWHKj67AA50Vqt1pI 05Jw== X-Forwarded-Encrypted: i=1; AJvYcCVokzFjbZGxTBNpmC9vITs7s05Sf0Yb9HhKwXsdyU4zSWd45XCPyl0SzNdGO9ylyHOvRf26zbMFD/p9eUf9sdqcwodOu7LDriwDzfaoHJ9ML8/F X-Gm-Message-State: AOJu0YzbbAVkULFMi+f5v0eiBVXN0RUq8B5Cix0HY4zXup2oUZB/0VVv Lu+6nvJHY+QqnEwLvEVqRMHXfWzNl5PM5u9EmUMQZ7tTUa/Zxv+qHNwvs7LnKP2Ztq2Dj0hXiOs m3+g= X-Google-Smtp-Source: AGHT+IHNtjNCgQ5qFBSrh4HY4SeBTaA3RxbJkCkMttl9WA6Ga33X1rxqR/OSuK2BZ9s3a+b1wPnzwg== X-Received: by 2002:a17:906:6a0f:b0:a77:dafb:2bf9 with SMTP id a640c23a62f3a-a7d4017958emr812837766b.49.1722360247574; Tue, 30 Jul 2024 10:24:07 -0700 (PDT) Received: from dynamic-pd01.res.v6.highway.a1.net ([2001:871:260:194:69a0:c22d:cd82:b639]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7acad90486sm666866766b.150.2024.07.30.10.24.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jul 2024 10:24:07 -0700 (PDT) Message-ID: <85cc2eb0ca709ab753e618584f46dbf8801e9658.camel@cybertec.at> Subject: Re: Trigger usecase From: Laurenz Albe To: sud , pgsql-general Date: Tue, 30 Jul 2024 19:24:06 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.52.3 (3.52.3-1.fc40) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, 2024-07-30 at 20:46 +0530, sud wrote: > Now while loading transactions data we also get some reference data infor= mation from > source (for example customer information) and for these , we dont want to= modify or > override the existing customer data but want to keep the old data with a = flag as > inactive and the new record should get inserted with flag as active. So f= or such > use case , should we cater this inside the apache flink application code = or should > we handle this using trigger on the table level which will execute on eac= h INSERT > and execute this logic?=C2=A0 >=20 > I understand trigger is difficult to debug and monitor stuff. But here in= this case , > team mates is saying , we shouldn't put such code logic into a streaming = application > code so should rather handle through trigger.=C2=A0 >=20 > I understand, technically its possible bith the way, but want to understa= nd experts > opinion on this and pros ans cons? It is largely a matter of taste. The advantage of a trigger is that it works even if somebody bypasses the a= pplication to insert data. I think that triggers are easy to debug, but again, that's a matter of tast= e. Yours, Laurenz Albe