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 1jBCQo-0000c2-2p for pgsql-general@arkaria.postgresql.org; Mon, 09 Mar 2020 07:02:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jBCQm-0002g3-S7 for pgsql-general@arkaria.postgresql.org; Mon, 09 Mar 2020 07:02:28 +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 1jBCQm-0002fo-EU for pgsql-general@lists.postgresql.org; Mon, 09 Mar 2020 07:02:28 +0000 Received: from hermes.gatewaynet.com ([193.92.121.98]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jBCQh-000785-Ks for pgsql-general@lists.postgresql.org; Mon, 09 Mar 2020 07:02:26 +0000 Received: from smadev.internal.net (pc131.internal.net [10.9.200.131]) by hermes.gatewaynet.com (8.15.2/8.15.2/Debian-8) with ESMTPS id 02972EFp028890 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 9 Mar 2020 09:02:19 +0200 Received: from smadev.internal.net (smadev [10.9.200.131]) by smadev.internal.net (8.15.2/8.15.2) with ESMTP id 02972EdR043201 for ; Mon, 9 Mar 2020 09:02:14 +0200 (EET) (envelope-from achill@matrix.gatewaynet.com) Subject: Re: Rules versus triggers To: pgsql-general@lists.postgresql.org References: <20200307115615.GA27155@panix.com> <20200307145718.GB10796@panix.com> From: Achilleas Mantzios Message-ID: <57571cc1-80c8-2496-483e-ee38425f7aee@matrix.gatewaynet.com> Date: Mon, 9 Mar 2020 09:02:14 +0200 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:60.0) Gecko/20100101 Thunderbird/60.3.2 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------A98BF274F6E2812C08CFB0F6" Content-Language: en-US X-Virus-Scanned: clamav-milter 0.101.4 at hermes X-Virus-Status: Clean X-Spam-Status: No, score=-28.0 required=5.0 tests=ALL_TRUSTED,DYN_HAM_COORD, DYN_HAM_IT,DYN_HAM_NAUTICAL,HTML_MESSAGE autolearn=unavailable autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on hermes.gatewaynet.com List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------A98BF274F6E2812C08CFB0F6 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 7/3/20 5:01 μ.μ., Justin wrote: > Yes a rule can rewrite query or replace the query > > Read through Depesz  post about rules and the weird side affects that can occurr > https://www.depesz.com/2010/06/15/to-rule-or-not-to-rule-that-is-the-question/ > IMHO Rules are cool. It allows for more elegant design (vs doing it otherwise) and it results in faster queries. In our system we have currently 61 rules and 331 triggers. > > > On Sat, Mar 7, 2020 at 9:57 AM stan > wrote: > > On Sat, Mar 07, 2020 at 09:47:39AM -0500, Justin wrote: > > Hi Stan > > > > Rules actual are able to rewrite the SQL query sent to postgresql.  Most > > everyone suggestion is avoid rules. > > > > Triggers are just like every other databases Triggers firing off code for > > Insert/Update/Delete/Truncate event > > https://www.postgresql.org/docs/current/sql-createtrigger.html > > > > So, the RULE can actually rewrite the query, instead of replacing it, > which is what I m doing in the function, correct? > -- > "They that would give up essential liberty for temporary safety deserve > neither liberty nor safety." >                                                 -- Benjamin Franklin > -- Achilleas Mantzios IT DEV Lead IT DEPT Dynacom Tankers Mgmt --------------A98BF274F6E2812C08CFB0F6 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit
On 7/3/20 5:01 μ.μ., Justin wrote:
Yes a rule can rewrite query or replace the query

Read through Depesz  post about rules and the weird side affects that can occurr

IMHO Rules are cool. It allows for more elegant design (vs doing it otherwise) and it results in faster queries. In our system we have currently 61 rules and 331 triggers.


On Sat, Mar 7, 2020 at 9:57 AM stan <stanb@panix.com> wrote:
On Sat, Mar 07, 2020 at 09:47:39AM -0500, Justin wrote:
> Hi Stan
>
> Rules actual are able to rewrite the SQL query sent to  postgresql.  Most
> everyone suggestion is avoid rules.
>
> Triggers are just like every other databases Triggers firing off code for
> Insert/Update/Delete/Truncate event
> https://www.postgresql.org/docs/current/sql-createtrigger.html
>

So, the RULE can actually rewrite the query, instead of replacing it,
which is what I m doing in the function, correct?
--
"They that would give up essential liberty for temporary safety deserve
neither liberty nor safety."
                                                -- Benjamin Franklin


-- 
Achilleas Mantzios
IT DEV Lead
IT DEPT
Dynacom Tankers Mgmt
--------------A98BF274F6E2812C08CFB0F6--