pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Rules versus triggers
6+ messages / 4 participants
[nested] [flat]

* Rules versus triggers
@ 2020-03-07 11:56 stan <stanb@panix.com>
  2020-03-07 14:38 ` Re: Rules versus triggers Steve Atkins <steve@blighty.com>
  2020-03-07 14:47 ` Re: Rules versus triggers Justin <zzzzz.graf@gmail.com>
  0 siblings, 2 replies; 6+ messages in thread

From: stan @ 2020-03-07 11:56 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

Could someone give me a brief description of the intended functionally, and
how the 2 features work of rules, versus triggers? It appears to me that
they are simply 2 different ways to set up triggers, but I am certain that
is just because of my lack of knowledge.

Thank you.

-- 
"They that would give up essential liberty for temporary safety deserve
neither liberty nor safety."
						-- Benjamin Franklin





^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Rules versus triggers
  2020-03-07 11:56 Rules versus triggers stan <stanb@panix.com>
@ 2020-03-07 14:38 ` Steve Atkins <steve@blighty.com>
  1 sibling, 0 replies; 6+ messages in thread

From: Steve Atkins @ 2020-03-07 14:38 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org


On 07/03/2020 11:56, stan wrote:
> Could someone give me a brief description of the intended functionally, and
> how the 2 features work of rules, versus triggers? It appears to me that
> they are simply 2 different ways to set up triggers, but I am certain that
> is just because of my lack of knowledge.

The pages 
https://wiki.postgresql.org/wiki/Don%27t_Do_This#Don.27t_use_rules links 
to will give you some idea of the differences.

Cheers,
   Steve






^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Rules versus triggers
  2020-03-07 11:56 Rules versus triggers stan <stanb@panix.com>
@ 2020-03-07 14:47 ` Justin <zzzzz.graf@gmail.com>
  2020-03-07 14:57   ` Re: Rules versus triggers stan <stanb@panix.com>
  1 sibling, 1 reply; 6+ messages in thread

From: Justin @ 2020-03-07 14:47 UTC (permalink / raw)
  To: stan <stanb@panix.com>; +Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>

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

On Sat, Mar 7, 2020 at 6:56 AM stan <stanb@panix.com> wrote:

> Could someone give me a brief description of the intended functionally, and
> how the 2 features work of rules, versus triggers? It appears to me that
> they are simply 2 different ways to set up triggers, but I am certain that
> is just because of my lack of knowledge.
>
> Thank you.
>
> --
> "They that would give up essential liberty for temporary safety deserve
> neither liberty nor safety."
>                                                 -- Benjamin Franklin
>
>
>

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Rules versus triggers
  2020-03-07 11:56 Rules versus triggers stan <stanb@panix.com>
  2020-03-07 14:47 ` Re: Rules versus triggers Justin <zzzzz.graf@gmail.com>
@ 2020-03-07 14:57   ` stan <stanb@panix.com>
  2020-03-07 15:01     ` Re: Rules versus triggers Justin <zzzzz.graf@gmail.com>
  0 siblings, 1 reply; 6+ messages in thread

From: stan @ 2020-03-07 14:57 UTC (permalink / raw)
  To: Justin <zzzzz.graf@gmail.com>; +Cc: pgsql-general@lists.postgresql.org

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





^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Rules versus triggers
  2020-03-07 11:56 Rules versus triggers stan <stanb@panix.com>
  2020-03-07 14:47 ` Re: Rules versus triggers Justin <zzzzz.graf@gmail.com>
  2020-03-07 14:57   ` Re: Rules versus triggers stan <stanb@panix.com>
@ 2020-03-07 15:01     ` Justin <zzzzz.graf@gmail.com>
  2020-03-09 07:02       ` Re: Rules versus triggers Achilleas Mantzios <achill@matrix.gatewaynet.com>
  0 siblings, 1 reply; 6+ messages in thread

From: Justin @ 2020-03-07 15:01 UTC (permalink / raw)
  To: stan <stanb@panix.com>; +Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>

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/



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
>

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Rules versus triggers
  2020-03-07 11:56 Rules versus triggers stan <stanb@panix.com>
  2020-03-07 14:47 ` Re: Rules versus triggers Justin <zzzzz.graf@gmail.com>
  2020-03-07 14:57   ` Re: Rules versus triggers stan <stanb@panix.com>
  2020-03-07 15:01     ` Re: Rules versus triggers Justin <zzzzz.graf@gmail.com>
@ 2020-03-09 07:02       ` Achilleas Mantzios <achill@matrix.gatewaynet.com>
  0 siblings, 0 replies; 6+ messages in thread

From: Achilleas Mantzios @ 2020-03-09 07:02 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

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 <stanb@panix.com <mailto: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

^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2020-03-09 07:02 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-03-07 11:56 Rules versus triggers stan <stanb@panix.com>
2020-03-07 14:38 ` Steve Atkins <steve@blighty.com>
2020-03-07 14:47 ` Justin <zzzzz.graf@gmail.com>
2020-03-07 14:57   ` stan <stanb@panix.com>
2020-03-07 15:01     ` Justin <zzzzz.graf@gmail.com>
2020-03-09 07:02       ` Achilleas Mantzios <achill@matrix.gatewaynet.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox