Execution plan cache for PL/pgSQL functions in PostgreSQL

你离开我真会死。 提交于 2019-12-04 05:54:52

问题


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:


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.



来源:https://stackoverflow.com/questions/46698386/execution-plan-cache-for-pl-pgsql-functions-in-postgresql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!