Say you have a View that selects a couple properties from a table. One of them is an inline function. After the view is created, will it execute the inline function if I don't select that property from the view?
CREATE OR REPLACE VIEW my_view AS
SELECT colA, colB, my_custom_function(colA) colC
FROM my_table;
Will the below query still execute the aforementioned my_custom_function?
SELECT colA, colB FROM my_view;
No.
You can test it yourself:
Then:
Then:
If it does call the function then the query will take 5 seconds and if it doesn't call the function then it will return quickly.
The query returns quickly so the function is not called.
You can compare it to:
Which takes 5 seconds to return the row.
db<>fiddle here