mirror of
https://github.com/HypoPG/hypopg
synced 2026-05-23 17:18:44 +00:00
Fixup for index hiding patch.
Fix compatibility for pg12- servers, and while at it remove some uncessary trailing whitespaces.
This commit is contained in:
parent
351f14a79d
commit
9385d5e25e
4 changed files with 26 additions and 22 deletions
16
README.md
16
README.md
|
|
@ -109,7 +109,7 @@ Create two real indexes and run `EXPLAIN`:
|
|||
rjuju=# CREATE INDEX ON hypo(id);
|
||||
rjuju=# CREATE INDEX ON hypo(id, val);
|
||||
rjuju=# EXPLAIN SELECT * FROM hypo WHERE id = 1;
|
||||
QUERY PLAN
|
||||
QUERY PLAN
|
||||
----------------------------------------------------------------------------------
|
||||
Index Only Scan using hypo_id_val_idx on hypo (cost=0.29..8.30 rows=1 width=13)
|
||||
Index Cond: (id = 1)
|
||||
|
|
@ -119,7 +119,7 @@ The query plan is using the `hypo_id_val_idx` index. Use `hypopg_hide_index(oid)
|
|||
|
||||
rjuju=# SELECT hypopg_hide_index('hypo_id_val_idx'::REGCLASS);
|
||||
rjuju=# EXPLAIN SELECT * FROM hypo WHERE id = 1;
|
||||
QUERY PLAN
|
||||
QUERY PLAN
|
||||
-------------------------------------------------------------------------
|
||||
Index Scan using hypo_id_idx on hypo (cost=0.29..8.30 rows=1 width=13)
|
||||
Index Cond: (id = 1)
|
||||
|
|
@ -129,7 +129,7 @@ The query plan is using the other index `hypo_id_idx` now. Use `hypopg_hide_inde
|
|||
|
||||
rjuju=# SELECT hypopg_hide_index('hypo_id_idx'::REGCLASS);
|
||||
rjuju=# EXPLAIN SELECT * FROM hypo WHERE id = 1;
|
||||
QUERY PLAN
|
||||
QUERY PLAN
|
||||
-------------------------------------------------------
|
||||
Seq Scan on hypo (cost=0.00..180.00 rows=1 width=13)
|
||||
Filter: (id = 1)
|
||||
|
|
@ -139,7 +139,7 @@ And now the query plan changes back to `Seq Scan`. Use `hypopg_unhide_index(oid)
|
|||
|
||||
rjuju=# SELECT hypopg_unhide_index('hypo_id_idx'::regclass);
|
||||
rjuju=# EXPLAIN SELECT * FROM hypo WHERE id = 1;
|
||||
QUERY PLAN
|
||||
QUERY PLAN
|
||||
-------------------------------------------------------------------------
|
||||
Index Scan using hypo_id_idx on hypo (cost=0.29..8.30 rows=1 width=13)
|
||||
Index Cond: (id = 1)
|
||||
|
|
@ -149,7 +149,7 @@ Of course, you can also hide hypothetical indexes:
|
|||
|
||||
rjuju=# SELECT hypopg_create_index('CREATE INDEX ON hypo(id)');
|
||||
rjuju=# EXPLAIN SELECT * FROM hypo WHERE id = 1;
|
||||
QUERY PLAN
|
||||
QUERY PLAN
|
||||
------------------------------------------------------------------------------------
|
||||
Index Scan using "<12659>btree_hypo_id" on hypo (cost=0.04..8.05 rows=1 width=13)
|
||||
Index Cond: (id = 1)
|
||||
|
|
@ -157,7 +157,7 @@ Of course, you can also hide hypothetical indexes:
|
|||
|
||||
rjuju=# SELECT hypopg_hide_index(12659);
|
||||
rjuju=# EXPLAIN SELECT * FROM hypo WHERE id = 1;
|
||||
QUERY PLAN
|
||||
QUERY PLAN
|
||||
-------------------------------------------------------
|
||||
Seq Scan on hypo (cost=0.00..180.00 rows=1 width=13)
|
||||
Filter: (id = 1)
|
||||
|
|
@ -166,7 +166,7 @@ Of course, you can also hide hypothetical indexes:
|
|||
You can check which indexes are hidden using `hypopg_hidden_indexes()` or the `hypopg_hidden_indexes` view:
|
||||
|
||||
rjuju=# SELECT * FROM hypopg_hidden_indexes();
|
||||
indexid
|
||||
indexid
|
||||
---------
|
||||
526604
|
||||
526603
|
||||
|
|
@ -183,4 +183,4 @@ You can check which indexes are hidden using `hypopg_hidden_indexes()` or the `h
|
|||
|
||||
To restore all existing indexes, you can use the function `hypopg_unhide_all_indexes()`.
|
||||
Note that the functionality to hide existing indexes only applies to the EXPLAIN command in the current session
|
||||
and will not affect other sessions.
|
||||
and will not affect other sessions.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
.. title:: HypoPG: Hypothetical indexes for PostgreSQL
|
||||
.. title:: HypoPG: Hypothetical indexes for PostgreSQL
|
||||
|
||||
HypoPG
|
||||
======
|
||||
|
|
|
|||
|
|
@ -244,7 +244,7 @@ As a simple case, let's consider two indexes:
|
|||
:emphasize-lines: 4
|
||||
|
||||
EXPLAIN SELECT * FROM hypo WHERE id = 1;
|
||||
QUERY PLAN
|
||||
QUERY PLAN
|
||||
----------------------------------------------------------------------------------
|
||||
Index Only Scan using hypo_id_val_idx on hypo (cost=0.29..8.30 rows=1 width=13)
|
||||
Index Cond: (id = 1)
|
||||
|
|
@ -259,13 +259,13 @@ The query plan is using the **hypo_id_val_idx** index now.
|
|||
:emphasize-lines: 10
|
||||
|
||||
SELECT hypopg_hide_index('hypo_id_val_idx'::REGCLASS);
|
||||
hypopg_hide_index
|
||||
hypopg_hide_index
|
||||
-------------------
|
||||
t
|
||||
(1 row)
|
||||
|
||||
|
||||
EXPLAIN SELECT * FROM hypo WHERE id = 1;
|
||||
QUERY PLAN
|
||||
QUERY PLAN
|
||||
-------------------------------------------------------------------------
|
||||
Index Scan using hypo_id_idx on hypo (cost=0.29..8.30 rows=1 width=13)
|
||||
Index Cond: (id = 1)
|
||||
|
|
@ -278,13 +278,13 @@ To continue testing, use the **hypopg_hide_index(oid)** function to hide another
|
|||
:emphasize-lines: 10
|
||||
|
||||
SELECT hypopg_hide_index('hypo_id_idx'::REGCLASS);
|
||||
hypopg_hide_index
|
||||
hypopg_hide_index
|
||||
-------------------
|
||||
t
|
||||
(1 row)
|
||||
|
||||
EXPLAIN SELECT * FROM hypo WHERE id = 1;
|
||||
QUERY PLAN
|
||||
QUERY PLAN
|
||||
-------------------------------------------------------
|
||||
Seq Scan on hypo (cost=0.00..180.00 rows=1 width=13)
|
||||
Filter: (id = 1)
|
||||
|
|
@ -303,7 +303,7 @@ To continue testing, use the **hypopg_hide_index(oid)** function to hide another
|
|||
(1 row)
|
||||
|
||||
EXPLAIN SELECT * FROM hypo WHERE id = 1;
|
||||
QUERY PLAN
|
||||
QUERY PLAN
|
||||
-------------------------------------------------------------------------
|
||||
Index Scan using hypo_id_idx on hypo (cost=0.29..8.30 rows=1 width=13)
|
||||
Index Cond: (id = 1)
|
||||
|
|
@ -316,7 +316,7 @@ To continue testing, use the **hypopg_hide_index(oid)** function to hide another
|
|||
.. code-block:: psql
|
||||
|
||||
SELECT * FROM hypopg_hidden_indexes();
|
||||
indexid
|
||||
indexid
|
||||
---------
|
||||
526604
|
||||
(1 rows)
|
||||
|
|
@ -339,13 +339,13 @@ To continue testing, use the **hypopg_hide_index(oid)** function to hide another
|
|||
:emphasize-lines: 10
|
||||
|
||||
SELECT hypopg_create_index('CREATE INDEX ON hypo(id)');
|
||||
hypopg_create_index
|
||||
hypopg_create_index
|
||||
------------------------------
|
||||
(12659,<12659>btree_hypo_id)
|
||||
(1 row)
|
||||
|
||||
EXPLAIN SELECT * FROM hypo WHERE id = 1;
|
||||
QUERY PLAN
|
||||
QUERY PLAN
|
||||
------------------------------------------------------------------------------------
|
||||
Index Scan using "<12659>btree_hypo_id" on hypo (cost=0.04..8.05 rows=1 width=13)
|
||||
Index Cond: (id = 1)
|
||||
|
|
@ -363,7 +363,7 @@ Now that the hypothetical index is being used, we can try hiding it to see the c
|
|||
(1 row)
|
||||
|
||||
EXPLAIN SELECT * FROM hypo WHERE id = 1;
|
||||
QUERY PLAN
|
||||
QUERY PLAN
|
||||
-------------------------------------------------------------------------
|
||||
Index Scan using hypo_id_idx on hypo (cost=0.29..8.30 rows=1 width=13)
|
||||
Index Cond: (id = 1)
|
||||
|
|
@ -389,4 +389,4 @@ Now that the hypothetical index is being used, we can try hiding it to see the c
|
|||
indexrelid | index_name | schema_name | table_name | am_name | is_hypo
|
||||
-------------+----------------------+-------------+------------+---------+---------
|
||||
526604 | hypo_id_val_idx | public | hypo | btree | f
|
||||
(2 rows)
|
||||
(2 rows)
|
||||
|
|
|
|||
|
|
@ -1695,7 +1695,11 @@ hypopg_hidden_indexes(PG_FUNCTION_ARGS)
|
|||
|
||||
oldcontext = MemoryContextSwitchTo(rsinfo->econtext->ecxt_per_query_memory);
|
||||
|
||||
tupdesc = CreateTemplateTupleDesc(1);
|
||||
tupdesc = CreateTemplateTupleDesc(1
|
||||
#if PG_VERSION_NUM < 120000
|
||||
, false
|
||||
#endif
|
||||
);
|
||||
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "indexid", OIDOID, -1, 0);
|
||||
|
||||
tupstore = tuplestore_begin_heap(true, false, work_mem);
|
||||
|
|
|
|||
Loading…
Reference in a new issue