Unix Technical Forum

Partition: use triggers instead of rules

This is a discussion on Partition: use triggers instead of rules within the Pgsql Patches forums, part of the PostgreSQL category; --> Folks, Best practices for partitioning so far have shown that TRIGGERs are better than RULEs for most cases. Please ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql Patches

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-19-2008, 07:23 AM
David Fetter
 
Posts: n/a
Default Partition: use triggers instead of rules

Folks,

Best practices for partitioning so far have shown that TRIGGERs are
better than RULEs for most cases. Please find attached a patch which
reflects this.

Thanks to Robert Treat for help putting this together

Cheers,
David.
--
David Fetter <david@fetter.org> http://fetter.org/
Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
Skype: davidfetter XMPP: david.fetter@gmail.com

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate


---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-19-2008, 07:23 AM
David Fetter
 
Posts: n/a
Default Re: [DOCS] Partition: use triggers instead of rules

On Wed, Nov 28, 2007 at 12:39:04PM -0800, Joshua D. Drake wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On Wed, 28 Nov 2007 12:26:15 -0800
> David Fetter <david@fetter.org> wrote:
>
> > Folks,
> >
> > Best practices for partitioning so far have shown that TRIGGERs are
> > better than RULEs for most cases. Please find attached a patch which
> > reflects this.
> >
> > Thanks to Robert Treat for help putting this together
> >
> > Cheers,
> > David.

>
> +1
>
> Joshua D. Drake


Per Robert, I've also dropped the UNION partitioning suggestion as
it's pretty useless.

Cheers,
David.
--
David Fetter <david@fetter.org> http://fetter.org/
Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
Skype: davidfetter XMPP: david.fetter@gmail.com

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate


---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-19-2008, 07:23 AM
Tom Lane
 
Posts: n/a
Default Re: [DOCS] Partition: use triggers instead of rules

David Fetter <david@fetter.org> writes:
> On Wed, Nov 28, 2007 at 03:53:04PM -0500, Tom Lane wrote:
>> Entirely removing the example of how to do it with rules doesn't
>> seem like a good idea.


> It does to me. I haven't found a case yet where rules worked even as
> well as triggers.


I don't have a problem with emphasizing triggers as the preferred
solution, but we should keep the older example, if only because people
are going to see DB schemas that use that approach, and they won't
understand what's going on (or realize they could convert) if they've
not seen an example.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-19-2008, 07:23 AM
David Fetter
 
Posts: n/a
Default Re: [DOCS] Partition: use triggers instead of rules

On Wed, Nov 28, 2007 at 05:17:38PM -0500, Tom Lane wrote:
> David Fetter <david@fetter.org> writes:
> > On Wed, Nov 28, 2007 at 03:53:04PM -0500, Tom Lane wrote:
> >> Entirely removing the example of how to do it with rules doesn't
> >> seem like a good idea.

>
> > It does to me. I haven't found a case yet where rules worked even
> > as well as triggers.

>
> I don't have a problem with emphasizing triggers as the preferred
> solution, but we should keep the older example, if only because
> people are going to see DB schemas that use that approach, and they
> won't understand what's going on (or realize they could convert) if
> they've not seen an example.


Greg Sabino Mullane managed to contrive an example where RULEs might
conceivably be the least-bad way to do this, that being a machine
where no PLs may be installed.

Telling people how to do this is not *quite* as bad as describing how
to do EAV, but it's pretty close.

Cheers,
David.
--
David Fetter <david@fetter.org> http://fetter.org/
Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
Skype: davidfetter XMPP: david.fetter@gmail.com

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-19-2008, 07:23 AM
Alvaro Herrera
 
Posts: n/a
Default Re: [DOCS] Partition: use triggers instead of rules

David Fetter wrote:

> Greg Sabino Mullane managed to contrive an example where RULEs might
> conceivably be the least-bad way to do this, that being a machine
> where no PLs may be installed.


Perhaps this just means we should consider installing plpgsql by
default.

--
Alvaro Herrera http://www.amazon.com/gp/registry/5ZYLFMCVHXC
"There was no reply" (Kernel Traffic)

---------------------------(end of broadcast)---------------------------
TIP 7: You can help support the PostgreSQL project by donating at

http://www.postgresql.org/about/donate

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 04-19-2008, 07:23 AM
Jonah H. Harris
 
Posts: n/a
Default Re: [DOCS] Partition: use triggers instead of rules

On Nov 28, 2007 3:53 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Entirely removing the example of how to do it with rules doesn't
> seem like a good idea.


Agreed.

--
Jonah H. Harris, Sr. Software Architect | phone: 732.331.1324
EnterpriseDB Corporation | fax: 732.331.1301
499 Thornall Street, 2nd Floor | jonah.harris@enterprisedb.com
Edison, NJ 08837 | http://www.enterprisedb.com/

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 04-19-2008, 07:23 AM
David Fetter
 
Posts: n/a
Default Re: [DOCS] Partition: use triggers instead of rules

On Wed, Nov 28, 2007 at 09:58:26PM -0500, Jonah H. Harris wrote:
> On Nov 28, 2007 3:53 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> > Entirely removing the example of how to do it with rules doesn't
> > seem like a good idea.

>
> Agreed.


Do you have an example of one use case where using RULEs rather than
TRIGGERs is a good idea?

Cheers,
David.
--
David Fetter <david@fetter.org> http://fetter.org/
Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
Skype: davidfetter XMPP: david.fetter@gmail.com

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 04-19-2008, 07:23 AM
Jeremy Drake
 
Posts: n/a
Default Re: [DOCS] Partition: use triggers instead of rules

On Wed, 28 Nov 2007, Alvaro Herrera wrote:

> David Fetter wrote:
>
> > Greg Sabino Mullane managed to contrive an example where RULEs might
> > conceivably be the least-bad way to do this, that being a machine
> > where no PLs may be installed.

>
> Perhaps this just means we should consider installing plpgsql by
> default.


I have run into this myself, and a patch that I contributed (which made it
in to 8.3) made it possible for a database owner to create trusted
languages from templates in the default configuration. Which means that
if an admin wants to prevent usage of the language, they can revoke the
right to create it, but db owners still "opt-in" to any languages they
want.


---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 04-19-2008, 07:23 AM
David Fetter
 
Posts: n/a
Default Re: [DOCS] Partition: use triggers instead of rules

On Thu, Nov 29, 2007 at 12:55:53AM -0500, Tom Lane wrote:
> David Fetter <david@fetter.org> writes:
> > On Wed, Nov 28, 2007 at 09:58:26PM -0500, Jonah H. Harris wrote:
> >> On Nov 28, 2007 3:53 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> >>> Entirely removing the example of how to do it with rules doesn't
> >>> seem like a good idea.
> >>
> >> Agreed.

>
> > Do you have an example of one use case where using RULEs rather
> > than TRIGGERs is a good idea?

>
> The argument I made for keeping the example around is not dependent
> on the assumption that using a rule is a good idea. It's dependent
> on the established fact that we have recommended that in prior
> releases, and therefore people are going to be seeing that construct
> in real databases.


We've corrected mistakes in the manual before

Cheers,
David.
--
David Fetter <david@fetter.org> http://fetter.org/
Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
Skype: davidfetter XMPP: david.fetter@gmail.com

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 04-19-2008, 07:23 AM
NikhilS
 
Posts: n/a
Default Re: [DOCS] Partition: use triggers instead of rules

>
> > The argument I made for keeping the example around is not dependent on
> > the assumption that using a rule is a good idea. It's dependent on
> > the established fact that we have recommended that in prior releases,
> > and therefore people are going to be seeing that construct in real
> > databases.

>
> And they could refer back to the older version of the documentation for
> it. In fact, we should mention that in the patch:
>
> <note><para>If you have a partitioning setup that uses rules please
> refer to the 8.2 documentation on partitioning</para></note>
>


+1

Regards,
Nikhils
--
EnterpriseDB http://www.enterprisedb.com

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 04:49 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com