[pgpool-hackers: 160] Suggested patch for check_temp_table setting
Matt Solnit
msolnit at soasta.com
Fri Dec 28 16:18:22 JST 2012
Hi everyone. I've been experimenting with the new "check_temp_table" setting
that was introduced in version 3.2. Setting it to "off" definitely reduces the
number of queries sent to the master, which is great. However, pgpool-II is
still preventing system catalog queries from being load-balanced. From the
comments, it sounds like the only reason for doing this is to accommodate temporary
tables:
pool_query_context.c, lines 422-437:
/*
* If system catalog is used in the SELECT, we
* prefer to send to the primary. Example: SELECT
* * FROM pg_class WHERE relname = 't1'; Because
* 't1' is a constant, it's hard to recognize as
* table name. Most use case such query is
* against system catalog, and the table name can
* be a temporary table, it's best to query
* against primary system catalog.
* Please note that this test must be done *before*
* test using pool_has_temp_table.
*/
else if (pool_has_system_catalog(node))
{
pool_set_node_to_be_sent(query_context, PRIMARY_NODE_ID);
}
Is there any reason not to use check_temp_table here as well? The following
change is working fine for me, and has significantly reduced the amount of
traffic going to the master, especially during application start-up (when Hibernate
and the JDBC driver seem to generate a lot of pg_catalog queries).
diff --git a/pool_query_context.c b/pool_query_context.c
index 6dbe397..bb84563 100644
--- a/pool_query_context.c
+++ b/pool_query_context.c
@@ -434 +434 @@ void pool_where_to_send(POOL_QUERY_CONTEXT *query_context, char *query, Node *no
- else if (pool_has_system_catalog(node))
+ else if (pool_config->check_temp_table && pool_has_system_catalog(node))
-- Matt
More information about the pgpool-hackers
mailing list