From 3057465acfbea2f3dd7a914a1478064022c6eecd Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Fri, 14 Oct 2022 12:26:39 -0400 Subject: Replace the sorted array of GUC variables with a hash table. This gets rid of bsearch() in favor of hashed lookup. The main advantage is that it becomes far cheaper to add new GUCs, since we needn't re-sort the pointer array. Adding N new GUCs had been O(N^2 log N), but now it's closer to O(N). We need to sort only in SHOW ALL and equivalent functions, which are hopefully not performance-critical to anybody. Also, merge GetNumConfigOptions() into get_guc_variables(), because in a world where the set of GUCs isn't fairly static you really want to consider those two results as tied together not independent. Discussion: https://postgr.es/m/2982579.1662416866@sss.pgh.pa.us --- src/include/utils/guc.h | 1 - src/include/utils/guc_tables.h | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'src/include') diff --git a/src/include/utils/guc.h b/src/include/utils/guc.h index c8b65c5bb8f..b3aaff9665b 100644 --- a/src/include/utils/guc.h +++ b/src/include/utils/guc.h @@ -390,7 +390,6 @@ extern int set_config_option_ext(const char *name, const char *value, extern void AlterSystemSetConfigFile(AlterSystemStmt *altersysstmt); extern char *GetConfigOptionByName(const char *name, const char **varname, bool missing_ok); -extern int GetNumConfigOptions(void); extern void ProcessGUCArray(ArrayType *array, GucContext context, GucSource source, GucAction action); diff --git a/src/include/utils/guc_tables.h b/src/include/utils/guc_tables.h index b3d2a959c3a..99740e7e48c 100644 --- a/src/include/utils/guc_tables.h +++ b/src/include/utils/guc_tables.h @@ -281,7 +281,7 @@ extern struct config_generic **get_explain_guc_options(int *num); extern char *ShowGUCOption(struct config_generic *record, bool use_units); /* get the current set of variables */ -extern struct config_generic **get_guc_variables(void); +extern struct config_generic **get_guc_variables(int *num_vars); extern void build_guc_variables(void); -- cgit v1.2.3