Answer the question
In order to leave comments, you need to log in
What are the benefits of stored procedures in PostgreSQL?
Hi all!
Do you think there are any real benefits to using postgresql storage?
For example, I write work with data on JDBC, and it would be possible to pack large transactions into storages. Large transactions mean many inserts into different tables and updates of many records in one transaction.
Will there be a performance gain? And in general, what kind of rake can lie in wait on this path?
Answer the question
In order to leave comments, you need to log in
It is categorically not recommended to put business logic in the database. Think about the complexity of debugging.
There will definitely be a performance gain, at least due to the fact that the overhead costs for connecting to the database and transferring information over the network are removed. But the complexity of debugging these same stored procedures will immediately increase, and the cost of an error, especially on large databases. Stores IMHO are very difficult to cover with automatic tests
If there is really a lot of business logic, then yes, but if only CRUD. In one case, the request comes from java (the same sql), and in the other it is stored in the database. Unit tests will still have mocks. Or is there some other difficulty?
How is it stored in postgres? Do they compile in it? For example, in SQL server, storages are compiled, which increases performance.
I remember in 2005 it was fashionable to use storage. And there were plenty of holivars on this topic. Many did everything CRUD through storages and pulled through ado.net (hello dotnetchik)
The main benefit from storage is less traffic. If you don't care about traffic, you probably don't need them. Sometimes storages still restrict access to the database. All requests then go through . It is impossible to do something unforeseen in case of hacking. It also has the right to life.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question