mirror of
				https://github.com/postgres/postgres.git
				synced 2025-10-29 22:49:41 +03:00 
			
		
		
		
	Change default of pg_stat_statements.track_planning to off.
Since v13 pg_stat_statements is allowed to track the planning time of statements when track_planning option is enabled. Its default was on. But this feature could cause more terrible spinlock contentions in pg_stat_statements. As a result of this, Robins Tharakan reported that v13 beta1 showed ~45% performance drop at high DB connection counts (when compared with v12.3) during fully-cached SELECT-only test using pgbench. To avoid this performance regression by the default setting, this commit changes default of pg_stat_statements.track_planning to off. Back-patch to v13 where pg_stat_statements.track_planning was introduced. Reported-by: Robins Tharakan Author: Fujii Masao Reviewed-by: Julien Rouhaud Discussion: https://postgr.es/m/2895b53b033c47ccb22972b589050dd9@EX13D05UWC001.ant.amazon.com
This commit is contained in:
		| @@ -3,6 +3,7 @@ CREATE EXTENSION pg_stat_statements; | |||||||
| -- simple and compound statements | -- simple and compound statements | ||||||
| -- | -- | ||||||
| SET pg_stat_statements.track_utility = FALSE; | SET pg_stat_statements.track_utility = FALSE; | ||||||
|  | SET pg_stat_statements.track_planning = TRUE; | ||||||
| SELECT pg_stat_statements_reset(); | SELECT pg_stat_statements_reset(); | ||||||
|  pg_stat_statements_reset  |  pg_stat_statements_reset  | ||||||
| -------------------------- | -------------------------- | ||||||
|   | |||||||
| @@ -442,7 +442,7 @@ _PG_init(void) | |||||||
| 							 "Selects whether planning duration is tracked by pg_stat_statements.", | 							 "Selects whether planning duration is tracked by pg_stat_statements.", | ||||||
| 							 NULL, | 							 NULL, | ||||||
| 							 &pgss_track_planning, | 							 &pgss_track_planning, | ||||||
| 							 true, | 							 false, | ||||||
| 							 PGC_SUSET, | 							 PGC_SUSET, | ||||||
| 							 0, | 							 0, | ||||||
| 							 NULL, | 							 NULL, | ||||||
|   | |||||||
| @@ -4,6 +4,7 @@ CREATE EXTENSION pg_stat_statements; | |||||||
| -- simple and compound statements | -- simple and compound statements | ||||||
| -- | -- | ||||||
| SET pg_stat_statements.track_utility = FALSE; | SET pg_stat_statements.track_utility = FALSE; | ||||||
|  | SET pg_stat_statements.track_planning = TRUE; | ||||||
| SELECT pg_stat_statements_reset(); | SELECT pg_stat_statements_reset(); | ||||||
|  |  | ||||||
| SELECT 1 AS "int"; | SELECT 1 AS "int"; | ||||||
|   | |||||||
| @@ -101,6 +101,8 @@ | |||||||
|       </para> |       </para> | ||||||
|       <para> |       <para> | ||||||
|        Number of times the statement was planned |        Number of times the statement was planned | ||||||
|  |        (if <varname>pg_stat_statements.track_planning</varname> is enabled, | ||||||
|  |        otherwise zero) | ||||||
|       </para></entry> |       </para></entry> | ||||||
|      </row> |      </row> | ||||||
|  |  | ||||||
| @@ -110,6 +112,8 @@ | |||||||
|       </para> |       </para> | ||||||
|       <para> |       <para> | ||||||
|        Total time spent planning the statement, in milliseconds |        Total time spent planning the statement, in milliseconds | ||||||
|  |        (if <varname>pg_stat_statements.track_planning</varname> is enabled, | ||||||
|  |        otherwise zero) | ||||||
|       </para></entry> |       </para></entry> | ||||||
|      </row> |      </row> | ||||||
|  |  | ||||||
| @@ -119,6 +123,8 @@ | |||||||
|       </para> |       </para> | ||||||
|       <para> |       <para> | ||||||
|        Minimum time spent planning the statement, in milliseconds |        Minimum time spent planning the statement, in milliseconds | ||||||
|  |        (if <varname>pg_stat_statements.track_planning</varname> is enabled, | ||||||
|  |        otherwise zero) | ||||||
|       </para></entry> |       </para></entry> | ||||||
|      </row> |      </row> | ||||||
|  |  | ||||||
| @@ -128,6 +134,8 @@ | |||||||
|       </para> |       </para> | ||||||
|       <para> |       <para> | ||||||
|        Maximum time spent planning the statement, in milliseconds |        Maximum time spent planning the statement, in milliseconds | ||||||
|  |        (if <varname>pg_stat_statements.track_planning</varname> is enabled, | ||||||
|  |        otherwise zero) | ||||||
|       </para></entry> |       </para></entry> | ||||||
|      </row> |      </row> | ||||||
|  |  | ||||||
| @@ -137,6 +145,8 @@ | |||||||
|       </para> |       </para> | ||||||
|       <para> |       <para> | ||||||
|        Mean time spent planning the statement, in milliseconds |        Mean time spent planning the statement, in milliseconds | ||||||
|  |        (if <varname>pg_stat_statements.track_planning</varname> is enabled, | ||||||
|  |        otherwise zero) | ||||||
|       </para></entry> |       </para></entry> | ||||||
|      </row> |      </row> | ||||||
|  |  | ||||||
| @@ -145,7 +155,10 @@ | |||||||
|        <structfield>stddev_plan_time</structfield> <type>double precision</type> |        <structfield>stddev_plan_time</structfield> <type>double precision</type> | ||||||
|       </para> |       </para> | ||||||
|       <para> |       <para> | ||||||
|        Population standard deviation of time spent planning the statement, in milliseconds |        Population standard deviation of time spent planning the statement, | ||||||
|  |        in milliseconds | ||||||
|  |        (if <varname>pg_stat_statements.track_planning</varname> is enabled, | ||||||
|  |        otherwise zero) | ||||||
|       </para></entry> |       </para></entry> | ||||||
|      </row> |      </row> | ||||||
|  |  | ||||||
| @@ -594,7 +607,7 @@ | |||||||
|      <para> |      <para> | ||||||
|       <varname>pg_stat_statements.track_planning</varname> controls whether |       <varname>pg_stat_statements.track_planning</varname> controls whether | ||||||
|       planning operations and duration are tracked by the module. |       planning operations and duration are tracked by the module. | ||||||
|       The default value is <literal>on</literal>. |       The default value is <literal>off</literal>. | ||||||
|       Only superusers can change this setting. |       Only superusers can change this setting. | ||||||
|      </para> |      </para> | ||||||
|     </listitem> |     </listitem> | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user