Issue (#47): Default values of setting are not set properly.
parent
680d7a6ab1
commit
d66a079b1b
28
README.md
28
README.md
|
@ -69,20 +69,20 @@ make USE_PGXS=1 install
|
||||||
Here is the complete list of configuration parameters.
|
Here is the complete list of configuration parameters.
|
||||||
|
|
||||||
```
|
```
|
||||||
postgres=# select name,value, minimum, maximum from pg_stat_monitor_settings;
|
postgres=# select * from pg_stat_monitor_settings;
|
||||||
name | value | minimum | maximum
|
name | value | default_value | description | minimum | maximum | restart
|
||||||
-----------------------------------------------+--------+---------+------------
|
-----------------------------------------------+--------+---------------+-------------------------------------------------------------------+---------+------------+---------
|
||||||
pg_stat_monitor.pgsm_max | 5000 | 5000 | 2147483647
|
pg_stat_monitor.pgsm_max | 5000 | 5000 | Sets the maximum number of statements tracked by pg_stat_monitor. | 5000 | 2147483647 | 1
|
||||||
pg_stat_monitor.pgsm_query_max_len | 1024 | 1024 | 2147483647
|
pg_stat_monitor.pgsm_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | 1
|
||||||
pg_stat_monitor.pgsm_enable | 1 | 0 | 0
|
pg_stat_monitor.pgsm_enable | 1 | 1 | Enable/Disable statistics collector. | 0 | 0 | 1
|
||||||
pg_stat_monitor.pgsm_track_utility | 1 | 0 | 0
|
pg_stat_monitor.pgsm_track_utility | 1 | 0 | Selects whether utility commands are tracked. | 0 | 0 | 0
|
||||||
pg_stat_monitor.pgsm_normalized_query | 1 | 0 | 0
|
pg_stat_monitor.pgsm_normalized_query | 1 | 0 | Selects whether save query in normalized format. | 0 | 0 | 0
|
||||||
pg_stat_monitor.pgsm_max_buckets | 10 | 1 | 10
|
pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | 1
|
||||||
pg_stat_monitor.pgsm_bucket_time | 60 | 1 | 2147483647
|
pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | 1
|
||||||
pg_stat_monitor.pgsm_object_cache | 500000 | 5 | 10
|
pg_stat_monitor.pgsm_object_cache | 50 | 50 | Sets the maximum number of object cache | 50 | 2147483647 | 1
|
||||||
pg_stat_monitor.pgsm_respose_time_lower_bound | 5 | 1 | 2147483647
|
pg_stat_monitor.pgsm_respose_time_lower_bound | 1 | 1 | Sets the time in millisecond. | 1 | 2147483647 | 1
|
||||||
pg_stat_monitor.pgsm_respose_time_step | 1 | 1 | 2147483647
|
pg_stat_monitor.pgsm_respose_time_step | 1 | 1 | Sets the respose time steps in millisecond. | 1 | 2147483647 | 1
|
||||||
pg_stat_monitor.pgsm_query_shared_buffer | 1 | 500000 | 2147483647
|
pg_stat_monitor.pgsm_query_shared_buffer | 500000 | 500000 | Sets the query shared_buffer size. | 500000 | 2147483647 | 1
|
||||||
(11 rows)
|
(11 rows)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
35
hash_query.c
35
hash_query.c
|
@ -3,7 +3,7 @@
|
||||||
* hash_query.c
|
* hash_query.c
|
||||||
* Track statement execution times across a whole database cluster.
|
* Track statement execution times across a whole database cluster.
|
||||||
*
|
*
|
||||||
* Copyright (c) 2008-2018, PostgreSQL Global Development Group
|
* Copyright (c) 2008-2020, PostgreSQL Global Development Group
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* contrib/pg_stat_monitor/hash_query.c
|
* contrib/pg_stat_monitor/hash_query.c
|
||||||
|
@ -71,28 +71,17 @@ pgss_shmem_startup(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
pgss->query_buf_size_bucket = PGSM_QUERY_BUF_SIZE / PGSM_MAX_BUCKETS;
|
pgss->query_buf_size_bucket = PGSM_QUERY_BUF_SIZE / PGSM_MAX_BUCKETS;
|
||||||
|
|
||||||
for (i = 0; i < PGSM_MAX_BUCKETS; i++)
|
for (i = 0; i < PGSM_MAX_BUCKETS; i++)
|
||||||
pgss_qbuf[i] = (unsigned char *) ShmemAlloc(pgss->query_buf_size_bucket);
|
pgss_qbuf[i] = (unsigned char *) ShmemAlloc(pgss->query_buf_size_bucket);
|
||||||
|
|
||||||
pgss_hash = hash_init("pg_stat_monitor: Queries hashtable",
|
pgss_hash = hash_init("pg_stat_monitor: Queries hashtable", sizeof(pgssHashKey), sizeof(pgssEntry),PGSM_MAX);
|
||||||
sizeof(pgssHashKey),
|
|
||||||
sizeof(pgssEntry),
|
|
||||||
PGSM_MAX);
|
|
||||||
|
|
||||||
pgss_buckethash = hash_init("pg_stat_monitor: Bucket hashtable",
|
pgss_buckethash = hash_init("pg_stat_monitor: Bucket hashtable", sizeof(pgssBucketHashKey), sizeof(pgssBucketEntry), PGSM_MAX_BUCKETS);
|
||||||
sizeof(pgssBucketHashKey),
|
|
||||||
sizeof(pgssBucketEntry),
|
|
||||||
PGSM_MAX_BUCKETS);
|
|
||||||
|
|
||||||
pgss_waiteventshash = hash_init("pg_stat_monitor: Wait Event hashtable",
|
pgss_waiteventshash = hash_init("pg_stat_monitor: Wait Event hashtable", sizeof(pgssWaitEventKey), sizeof(pgssWaitEventEntry), 100);
|
||||||
sizeof(pgssWaitEventKey),
|
|
||||||
sizeof(pgssWaitEventEntry),
|
|
||||||
100);
|
|
||||||
|
|
||||||
pgss_object_hash = hash_init("pg_stat_monitor: Object hashtable",
|
pgss_object_hash = hash_init("pg_stat_monitor: Object hashtable", sizeof(pgssObjectHashKey), sizeof(pgssObjectEntry), PGSM_OBJECT_CACHE);
|
||||||
sizeof(pgssObjectHashKey),
|
|
||||||
sizeof(pgssObjectEntry),
|
|
||||||
PGSM_OBJECT_CACHE);
|
|
||||||
|
|
||||||
Assert(IsHashInitialize());
|
Assert(IsHashInitialize());
|
||||||
|
|
||||||
|
@ -143,7 +132,6 @@ pgss_shmem_startup(void)
|
||||||
int
|
int
|
||||||
pgsm_get_bucket_size(void)
|
pgsm_get_bucket_size(void)
|
||||||
{
|
{
|
||||||
Assert(pgss->query_buf_size_bucket <= 0);
|
|
||||||
return pgss->query_buf_size_bucket;
|
return pgss->query_buf_size_bucket;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,26 +143,31 @@ pgssSharedState* pgsm_get_ss(void)
|
||||||
|
|
||||||
HTAB* pgsm_get_hash(void)
|
HTAB* pgsm_get_hash(void)
|
||||||
{
|
{
|
||||||
|
Assert(pgss_hash);
|
||||||
return pgss_hash;
|
return pgss_hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
pgssBucketEntry** pgsm_get_bucket_entries(void)
|
pgssBucketEntry** pgsm_get_bucket_entries(void)
|
||||||
{
|
{
|
||||||
|
Assert(pgssBucketEntries);
|
||||||
return pgssBucketEntries;
|
return pgssBucketEntries;
|
||||||
}
|
}
|
||||||
|
|
||||||
HTAB* pgsm_get_wait_event_hash(void)
|
HTAB* pgsm_get_wait_event_hash(void)
|
||||||
{
|
{
|
||||||
|
Assert(pgss_waiteventshash);
|
||||||
return pgss_waiteventshash;
|
return pgss_waiteventshash;
|
||||||
}
|
}
|
||||||
|
|
||||||
pgssBucketEntry** pgsm_get_bucket(void)
|
pgssBucketEntry** pgsm_get_bucket(void)
|
||||||
{
|
{
|
||||||
|
Assert(pgssBucketEntries);
|
||||||
return pgssBucketEntries;
|
return pgssBucketEntries;
|
||||||
}
|
}
|
||||||
|
|
||||||
pgssWaitEventEntry** pgsm_get_wait_event_entry(void)
|
pgssWaitEventEntry** pgsm_get_wait_event_entry(void)
|
||||||
{
|
{
|
||||||
|
Assert(pgssWaitEventEntries);
|
||||||
return pgssWaitEventEntries;
|
return pgssWaitEventEntries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -308,7 +301,7 @@ hash_entry_reset()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
add_object_entry(uint64 queryid, char *objects)
|
hash_alloc_object_entry(uint64 queryid, char *objects)
|
||||||
{
|
{
|
||||||
pgssObjectEntry *entry = NULL;
|
pgssObjectEntry *entry = NULL;
|
||||||
bool found;
|
bool found;
|
||||||
|
@ -328,7 +321,7 @@ add_object_entry(uint64 queryid, char *objects)
|
||||||
|
|
||||||
/* De-alocate memory */
|
/* De-alocate memory */
|
||||||
void
|
void
|
||||||
remove_object_entry(uint64 queryid, char *objects)
|
hash_dealloc_object_entry(uint64 queryid, char *objects)
|
||||||
{
|
{
|
||||||
pgssObjectHashKey key;
|
pgssObjectHashKey key;
|
||||||
pgssObjectEntry *entry;
|
pgssObjectEntry *entry;
|
||||||
|
@ -346,7 +339,7 @@ remove_object_entry(uint64 queryid, char *objects)
|
||||||
}
|
}
|
||||||
|
|
||||||
pgssEntry*
|
pgssEntry*
|
||||||
pgsm_create_query_entry(unsigned int queryid,
|
hash_create_query_entry(unsigned int queryid,
|
||||||
unsigned int userid,
|
unsigned int userid,
|
||||||
unsigned int dbid,
|
unsigned int dbid,
|
||||||
unsigned int bucket_id,
|
unsigned int bucket_id,
|
||||||
|
|
|
@ -259,7 +259,7 @@ pgss_post_parse_analyze(ParseState *pstate, Query *query)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
add_object_entry(query->queryId, tables_name);
|
hash_alloc_object_entry(query->queryId, tables_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -711,7 +711,7 @@ static void pgss_store(const char *query, uint64 queryId,
|
||||||
if (queryId == UINT64CONST(0))
|
if (queryId == UINT64CONST(0))
|
||||||
queryId = pgss_hash_string(query, query_len);
|
queryId = pgss_hash_string(query, query_len);
|
||||||
|
|
||||||
remove_object_entry(queryId, tables_name);
|
hash_dealloc_object_entry(queryId, tables_name);
|
||||||
len = strlen(tables_name);
|
len = strlen(tables_name);
|
||||||
|
|
||||||
/* Set up key for hashtable search */
|
/* Set up key for hashtable search */
|
||||||
|
|
|
@ -310,8 +310,8 @@ typedef struct pgssJumbleState
|
||||||
void init_guc(void);
|
void init_guc(void);
|
||||||
|
|
||||||
/* hash_create.c */
|
/* hash_create.c */
|
||||||
void add_object_entry(uint64 queryid, char *objects);
|
void hash_alloc_object_entry(uint64 queryid, char *objects);
|
||||||
void remove_object_entry(uint64 queryid, char *objects);
|
void hash_dealloc_object_entry(uint64 queryid, char *objects);
|
||||||
bool IsHashInitialize(void);
|
bool IsHashInitialize(void);
|
||||||
void pgss_shmem_startup(void);
|
void pgss_shmem_startup(void);
|
||||||
void pgss_shmem_shutdown(int code, Datum arg);
|
void pgss_shmem_shutdown(int code, Datum arg);
|
||||||
|
@ -327,7 +327,7 @@ void hash_entry_reset(void);
|
||||||
void hash_entry_dealloc(int bucket);
|
void hash_entry_dealloc(int bucket);
|
||||||
pgssEntry* hash_entry_alloc(pgssSharedState *pgss, pgssHashKey *key, int encoding);
|
pgssEntry* hash_entry_alloc(pgssSharedState *pgss, pgssHashKey *key, int encoding);
|
||||||
Size hash_memsize(void);
|
Size hash_memsize(void);
|
||||||
pgssEntry* pgsm_create_query_entry(unsigned int queryid, unsigned int userid, unsigned int dbid, unsigned int bucket_id, unsigned int ip);
|
pgssEntry* hash_create_query_entry(unsigned int queryid, unsigned int userid, unsigned int dbid, unsigned int bucket_id, unsigned int ip);
|
||||||
|
|
||||||
/*---- GUC variables ----*/
|
/*---- GUC variables ----*/
|
||||||
#define PGSM_MAX conf[0].guc_variable
|
#define PGSM_MAX conf[0].guc_variable
|
||||||
|
|
Loading…
Reference in New Issue