diff --git a/README.md b/README.md index 1626c9c..f4831e5 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,13 @@ The extension can be disabled with the `pg_query_settings.enabled` parameter. More informations on pg_query_settings -------------------------------------- +Load the library : + +``` +postgres=# LOAD 'pg_query_settings'; +LOAD +``` + Create the extension: ``` @@ -73,14 +80,6 @@ postgres=# INSERT INTO toto SELECT i, 'Ligne '||i FROM generate_series(1, 100000 INSERT 0 10000000 ``` -In order to retrieve the query id, you'll probably need to enable the -`compute_query_id` parameter in the same session : - -``` -postgres=# SET compute_query_id TO on; -SET -``` - We run a query that uses a sort : ``` @@ -146,36 +145,6 @@ INSERT 0 1 We execute the query : -``` -postgres=# EXPLAIN (COSTS OFF, ANALYZE, SETTINGS, VERBOSE) SELECT * FROM toto ORDER BY c2; -┌────────────────────────────────────────────────────────────────────────────────────┐ -│ QUERY PLAN │ -├────────────────────────────────────────────────────────────────────────────────────┤ -│ Sort (actual time=29046.787..41640.526 rows=10000000 loops=1) │ -│ Output: c1, c2 │ -│ Sort Key: toto.c2 │ -│ Sort Method: external merge Disk: 272920kB │ -│ -> Seq Scan on public.toto (actual time=0.035..12971.535 rows=10000000 loops=1) │ -│ Output: c1, c2 │ -│ Settings: random_page_cost = '1.1' │ -│ Query Identifier: 2507635424379213761 │ -│ Planning Time: 0.162 ms │ -│ Execution Time: 53110.755 ms │ -└────────────────────────────────────────────────────────────────────────────────────┘ -(10 rows) -``` - -Our configuration is not applied. That's OK, the library isn't loaded. - -We load the library : - -``` -postgres=# LOAD 'pg_query_settings'; -LOAD -``` - -We execute the query again: - ``` postgres=# EXPLAIN (COSTS OFF, ANALYZE, SETTINGS, VERBOSE) SELECT * FROM toto ORDER BY c2; WARNING: queryid is '2507635424379213761' diff --git a/pg_query_settings.c b/pg_query_settings.c index af20cb4..f17e297 100644 --- a/pg_query_settings.c +++ b/pg_query_settings.c @@ -18,6 +18,13 @@ #include #include #include + +#if (PG_VERSION_NUM >= 140000) && (PG_VERSION_NUM < 160000) +#include +#elif (PG_VERSION_NUM >= 160000) +#include +#endif + #include #include #include @@ -351,6 +358,10 @@ _PG_init(void) MarkGUCPrefixReserved("pg_query_settings"); #endif +#if PG_VERSION_NUM >= 140000 + EnableQueryId(); +#endif + if (debug) elog(DEBUG1,"Entering _PG_init()"); /* Set our two hooks */