• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Need a Better way for postgreSOL Triggers

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there
I am learning triggers in postgres, currently I have something similar to


I want to get rid of procduure and procedure call (for efficiency) Is there any way to write a trigger in postgreSOL similar to

 
Saloon Keeper
Posts: 22505
151
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, you'd be better off asking on the PostgreSQL site about stuff like that.

However, IIRC, PostgresSQL triggers do have to be in the form of a function.

Don't assume that function == inefficient. First of all, most modern-day language implementations do significant optimizations. Secondly, proportionally, the overhead of a stock function call to straightline code is a miniscule fraction of what it was 30 years ago. <advice>NEVER "KNOW" where ineficiency is. You'll be wrong. MEASURE it.</advice>

Finally, realize that database operations are thousands of times slower than program operations. So the time taken for the trigger to to its cascade delete (as you seem to be showing) or do foreign key operations or whatever is far more significant the overhead of a function call.
 
When it is used for evil, then watch out! When it is used for good, then things are much nicer. Like this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic