summaryrefslogtreecommitdiff
path: root/src/test/regress/expected/fsm.out
blob: b02993188cd5d806d2c134abbb877cf4c805c329 (plain)
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
--
-- Free Space Map test
--
CREATE TABLE fsm_check_size (num int, str text);
-- With one block, there should be no FSM
INSERT INTO fsm_check_size VALUES(1, 'a');
VACUUM fsm_check_size;
SELECT pg_relation_size('fsm_check_size', 'main') AS heap_size,
pg_relation_size('fsm_check_size', 'fsm') AS fsm_size;
 heap_size | fsm_size 
-----------+----------
      8192 |        0
(1 row)

-- Extend table with enough blocks to exceed the FSM threshold
DO $$
DECLARE curtid tid;
num int;
BEGIN
num = 11;
  LOOP
    INSERT INTO fsm_check_size VALUES (num, 'b') RETURNING ctid INTO curtid;
    EXIT WHEN curtid >= tid '(4, 0)';
    num = num + 1;
  END LOOP;
END;
$$;
VACUUM fsm_check_size;
SELECT pg_relation_size('fsm_check_size', 'fsm') AS fsm_size;
 fsm_size 
----------
    24576
(1 row)

-- Add long random string to extend TOAST table to 1 block
INSERT INTO fsm_check_size
VALUES(0, (SELECT string_agg(md5(chr(i)), '')
		   FROM generate_series(1,100) i));
VACUUM fsm_check_size;
SELECT pg_relation_size(reltoastrelid, 'main') AS toast_size,
pg_relation_size(reltoastrelid, 'fsm') AS toast_fsm_size
FROM pg_class WHERE relname = 'fsm_check_size';
 toast_size | toast_fsm_size 
------------+----------------
       8192 |              0
(1 row)

DROP TABLE fsm_check_size;