Re: Reason(s) not to use a stored procedure - Mailing list pgsql-novice

From Nick Nick
Subject Re: Reason(s) not to use a stored procedure
Date
Msg-id BAY131-W13D4D620801CC7257BDAB7C43E0@phx.gbl
Whole thread Raw
In response to Reason(s) not to use a stored procedure  ("Mag Gam" <magawake@gmail.com>)
List pgsql-novice
A. Kretschmer wrote:
> am Tue, dem 22.01.2008, um 8:49:39 -0500 mailte Mag Gam folgendes:
>> I was in an academic meeting where a professor was preaching the reasons why
>> not to use a stored procedure. He advised to always use SQL instead of a
>> procedural language. Can someone please shed some light on this?
>
> Why not use procedural languages? He told more about the reasons?
>

I assume that it is true for PostgreSQL as it was for Oracle that it is
less costly (in terms of computer resources) to select and filter data
at the RDBMS level with a single SQL call than at a higher level that
may involve more calls to the RDBMS. That will be even more true if
there's a network in between.

So if you can do something in SQL, that is likely to be the most
efficient way to do it (assuming optimally written code and indexes and
whatever).

But in the real world some things you might want to do may require such
contorted SQL (or may not even be possible in SQL at all) whereas using
a procedure would be simpler to write, understand (important for when it
needs to be revisited in a year's time and by someone else) and
maintain, and you might be able to make it perform better (if needed -
why bust a gut and waste money shaving a few minutes off a nightly run
when there's nobody there to see it finish anyway?).

Maybe the professor just sat in his ivory tower without a foot in the
real world, or hadn't seen it since the early 90s?

If you're doing a real-world job just do a real-world solution!

Nick.



Everything in one place. All new Windows Live!

pgsql-novice by date:

Previous
From: "A. Kretschmer"
Date:
Subject: Re: Reason(s) not to use a stored procedure
Next
From: Christoph Frick
Date:
Subject: Re: Reason(s) not to use a stored procedure