This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes Need a Better way for postgreSOL Triggers Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Need a Better way for postgreSOL Triggers" Watch "Need a Better way for postgreSOL Triggers" New topic

Need a Better way for postgreSOL Triggers

Michael Crowley

Joined: Oct 07, 2004
Posts: 10
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

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17260

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.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: Need a Better way for postgreSOL Triggers
It's not a secret anymore!