As I understand it, when you send a query to Postgres like:
SELECT id FROM table1 WHERE name = $1;
Postgres will create a query plan. The plan will be cached for the same query in the same session. But if you create a function:
CREATE OR REPLACE FUNCTION get_table1 (parname text) RETURNS bigint
LANGUAGE plpgsql AS
$$BEGIN
RETURN (SELECT id FROM table1 where name = parname);
END$$;
The query plan will be cached for all future sessions.
I'd like to verify this theory by checking how often the query analyzer is invoked. Is there a way to inspect the number of times Postgres parses a query?
If possible, I'd like to monitor things like #parses per second and the min/max/avg parse duration.
Aucun commentaire:
Enregistrer un commentaire