May 2017
Beginner
416 pages
10h 37m
English
As outlined in this section already, there are many optimizations which help to speedup queries. One of them is called function inlining. PostgreSQL is able to inline immutable SQL functions. The main idea is to reduce the number of function calls which have to be made to speed things up.
Here is an example of a function:
test=# CREATE OR REPLACE FUNCTION ld(int) RETURNS numeric AS $$ SELECT log(2, $1); $$ LANGUAGE 'sql' IMMUTABLE; CREATE FUNCTION
The function will calculate the logarithmus dualis of the input value:
test=# SELECT ld(1024); ld --------------------- 10.0000000000000000 (1 row)
To demonstrate how things work, I will recreate the table with less content to speedup the index creation:
Read now
Unlock full access