Execution plan cache for PL/pgSQL functions in Pos

2019-03-06 13:24发布

If I change PL/pgSQL function that is in use in another PL/pgSQL function will the PostgreSQL rebuild execution plan for both of them or only for changed one?

Say I have 2 functions using third one. Say function check_permission(user_id) is used by get_company(user_id) and get_location(user_id).

And I they got cached their execution plan somehow.

And then I change check_permission, would the execution plan caches for get_company(user_id) and get_location(user_id) be deleted and rebuilt on demand?

1条回答
Ridiculous、
2楼-- · 2019-03-06 14:12

PostgreSQL tracks dependencies, and it flushes caches pretty aggressively when things change.

If you change a function, it'll invalidate at least the plans of all functions that depend on it. In practice, IIRC it just flushes all cached query plans entirely.

The same is true of views that depend on other views, prepared statements that reference views, etc.

If you find a case where it fails to do so you have found a bug. Please report it with a complete reproducible test case.

查看更多
登录 后发表回答