[pgpool-committers: 5834] pgpool: Reduce internal queries against system catalogs.

Tatsuo Ishii ishii at sraoss.co.jp
Wed Jun 26 10:40:19 JST 2019


Reduce internal queries against system catalogs.

Currently the relcache module issues 7+ queries to obtain various info
from PostgreSQL system catalogs. Some of them are necessary for
Pgpool-II to work with multiple version of PostgreSQL.

Idea is, if we already know the version of PostgreSQL, we can
eliminate some of queries. For example, we need to know if
pg_namespace exists and for this purpose we send a query against
pg_class. But if we know that pg_namespace was introduced in
PostgreSQL 7.3, we do not need to inquire pg_class.

To implement this, new function:
PGVersion *
Pgversion(POOL_CONNECTION_POOL * backend)

is added and "SELECT version()" is used to get PostgreSQL's major and
minor version number (the minor version is not used for now). The
query itself is cached using relcache infrastructure. Plus Pgversion()
has its own cache using static memory. Thus obtaining PostgreSQL
version is quite fast for the second or later call to the function.

In my testing with "select * from t1" issues 7 queries. After the
patch, it reduces to 3. The remaining queries are:

- to know if it's a temporary table or not.
- to know if it's a unlogged table or not.
- to know if it's a system catalog table or not.

Discussion: [pgpool-hackers: 3344] Reducing query issued by relcache

Branch
------
master

Details
-------
https://git.postgresql.org/gitweb?p=pgpool2.git;a=commitdiff;h=6282805d4ae3f7a76ed607c0124420b8fe4c8320

Modified Files
--------------
src/include/pool.h             |  17 +++++
src/protocol/child.c           | 145 ++++++++++++++++++++++++++++++++++++++++-
src/utils/pool_select_walker.c | 121 +++++++++-------------------------
3 files changed, 190 insertions(+), 93 deletions(-)



More information about the pgpool-committers mailing list