PL/PGSQL Advantages

SQL is the language PostgreSQL and most other relational databases use as query language. But every SQL statement must be executed individually by the database server.
That means that your client application must send each query to the database server, wait for it to be processed, receive and process the results, do some computation, then send further queries to the server. All this incurs inter process communication and will also incur network overhead if your client is on a different machine than the database server.
With PL/pgSQL you can group a block of computation and a series of queries inside the database server, thus having the power of a procedural language and the ease of use of SQL, but with considerable savings of client/server communication overhead.

Extra round trips between client and server are eliminated.
Intermediate results that the client does not need do not have to be marshaled or transferred between server and client.
Multiple rounds of query parsing can be avoided.
This can result in a considerable performance increase as compared to an application that does not use stored functions.

Also, with PL/pgSQL you can use all the data types, operators and functions of SQL.


Popular posts from this blog

Oracle Database 19C Performance Tunning - PART 1

Oracle RMAN Backup And Restore

Oracle Patching Using Opatch Utility

Welcome to DBA Master – Database Tips, Tricks, and Tutorials

Oracle 19c Database Software Installation in OEL8

PostgreSQL Triggers

PostgreSQL Opensource Installation in RHEL or Oracle Linux(OEL) 8 and above

PostgreSQL Cursor

PostgreSQL Procedures

PostgreSQL User & Role Management