January 2019
Beginner
556 pages
14h 19m
English
The PL/pgSQL language caching is an amazing tool to increase performance; however, if the developer isn't careful, it may lead to bad execution of their plans. For example: let's assume that we want to wrap the following query in a function:
SELECT * FROM guru WHERE id <= <predicate>;
In this example, we shouldn't cache the execution plan, since the execution plan might differ depending on the predicate value. For example, if we use a value of 1 as the predicate, the execution planner will favor an Index Scan. However, if we use the 90,000 predicate, the planner will favor the use of a sequential scan. Due to this, caching the execution of this query is wrong. However, consider that the ...
Read now
Unlock full access