I do not see why stored procedures are particular better for asynchronous application design. this can be done, as some pointed before, using standard libraries.
Furthermore, while this does not apply to databases that do not burden users with heavy per-cpu costs, for many companies that build software to sell, it is a selling point that your system is light on database CPU utilization. So that your clients are not required to buy grotesquely overpowered DB servers just because your application had put its logic there.
Also framework, libraries and general community contributions of source code, code coverage tools -- are much more accessible in general purpose programming languages.
On Thu, Jul 25, 2013, at 04:51 AM, Bèrto ëd Sèra wrote:
Hi,>the whole design of this application is asynchronous in nature.Then you'll be MUCH better off with SPs, from an architectural POV, as you can basically design "building blocks" by initially just making SPs that deliver a mock result, and have the entire development of the app server being in dependent on the SQL development. This way none of the branches blocks the other (provided that you can actually freeze the design).CheersBèrtoOn 25 July 2013 09:44, Some Developer <someukdeveloper@xxxxxxxxx> wrote:On 25/07/13 08:14, Vincenzo Romano wrote:2013/7/25 Luca Ferrari <fluca1978@xxxxxxxxxxx>:On Thu, Jul 25, 2013 at 2:57 AM, Some Developer<someukdeveloper@xxxxxxxxx> wrote:The added advantage of removing load from the app servers so they canactually deal with serving the app is a bonus.Uhm...I don't know what application you are developing, but I don'tbuy your explaination.While it is true that you are moving CPU cycles from the applicationserver to the database server, you will probably end with theapplication server waiting for the database to acknowledge (andtherefore not serving requests) and usually the computation is notthat heavy for an online transaction (it would be better to do it asbatch if that is really heavy). Therefore this is not an advantage forme.Again, the only reason to use database facilities (like storedprocedures) is to arm the database so that even a differentapplication/connection/user will interact following as much businessrules as possible.Moreover, please also note that one reason developers tend to avoiddatabase facilities is that they are using some kind ofstack/orm/automagical library that does not allow the usage of deepfeatures in sake of portability.I'm not planning on creating a complex application in the database in itsown right, just augmenting what is already available with a few time saversand (a couple of) speed optimisations for commonly carried out tasks.I don't understand the "time saving" argument: you have to implementthe logic either in the application or the database, so let's say thetime of the implementation is the same. The only advantage of thedatabase is the code reuse. But take into account that there aredrawbacks, like debugging that is not always so simple.LucaI could be wrong, but the main advantage you gain by using storedprocedures is what Luca says: unique data access interface.Just that.I don't think you'll save a single CPU cycle by moving logic from"application" to "DB" (or the other way around).That logic need to be implemented (and run) on either part.The only saving would happen if you push the logic straight to the client.And keep in mind than not all PLs are the same and have the same effectiveness.So, for example, instead of INSERTing rows from program, you couldSELECT from a stored procedure which will do the INSERT possibly withthe very same checks you would do in the application. Only puttogether in a single place. The stored procedure.Finally, I fear this is kind of "religion" war. So feel free to followany or establish your own.The bottom line here is: PLs are OK. It just depends on what you do and how.When I was talking about improving speed I was talking about reducing load on the app servers by putting more of the work load on the database server. I know that it won't actually save CPU cycles (one of the machines has to do it) but it will save load on the app servers. As I said above using the asynchronous abilities of libpq helps keep the app servers serving requests whilst the database gets on with its tasks.In fact the whole design of this application is asynchronous in nature.--Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)To make changes to your subscription:--==============================If Pac-Man had affected us as kids, we'd all be running around in a darkened room munching pills and listening to repetitive music.
-- http://www.fastmail.fm - Faster than the air-speed velocity of an unladen european swallow