File: hypo_include.out

package info (click to toggle)
hypopg 1.4.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 464 kB
  • sloc: ansic: 2,338; sql: 357; makefile: 66; python: 51; sh: 2
file content (57 lines) | stat: -rw-r--r-- 1,351 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
-- hypothetical indexes using INCLUDE keyword, pg11+
-- Remove all the hypothetical indexes if any
SELECT hypopg_reset();
 hypopg_reset 
--------------
 
(1 row)

-- Make sure stats and visibility map are up to date
VACUUM ANALYZE hypo;
-- Should not use hypothetical index
-- Create normal index
SELECT COUNT(*) AS NB
FROM hypopg_create_index('CREATE INDEX ON hypo (id)');
 nb 
----
  1
(1 row)

-- Should use hypothetical index using a regular Index Scan
SELECT COUNT(*) FROM do_explain('SELECT val FROM hypo WHERE id = 1') e
WHERE e ~ 'Index Scan.*<\d+>btree_hypo.*';
 count 
-------
     1
(1 row)

-- Remove all the hypothetical indexes
SELECT hypopg_reset();
 hypopg_reset 
--------------
 
(1 row)

-- Create INCLUDE index
SELECT COUNT(*) AS NB
FROM hypopg_create_index('CREATE INDEX ON hypo (id) INCLUDE (val, "Id2")');
 nb 
----
  1
(1 row)

-- Should use hypothetical index using an Index Only Scan
SELECT COUNT(*) FROM do_explain('SELECT val FROM hypo WHERE id = 1') e
WHERE e ~ 'Index Only Scan.*<\d+>btree_hypo.*';
 count 
-------
     1
(1 row)

-- Deparse the index DDL
SELECT hypopg_get_indexdef(indexrelid) FROM hypopg();
                        hypopg_get_indexdef                        
-------------------------------------------------------------------
 CREATE INDEX ON public.hypo USING btree (id) INCLUDE (val, "Id2")
(1 row)