File: buffer_manager.test_slow

package info (click to toggle)
duckdb 1.5.1-3
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 299,196 kB
  • sloc: cpp: 865,414; ansic: 57,292; python: 18,871; sql: 12,663; lisp: 11,751; yacc: 7,412; lex: 1,682; sh: 747; makefile: 564
file content (78 lines) | stat: -rw-r--r-- 1,759 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# name: test/sql/storage/buffer_manager.test_slow
# description: Test that the buffer manager correctly frees any memory we use
# group: [storage]

require skip_reload

load

statement ok
PRAGMA temp_directory=''

statement ok
PRAGMA threads=1

statement ok
PRAGMA memory_limit='2MB'

# streaming results do not use any memory
query II
SELECT MIN(i), MAX(i) FROM range(1000001) tbl(i)
----
0	1000000

# increase memory limit 10MB because we always partition data in GROUP BY queries now (for potential out-of-core)
statement ok
PRAGMA memory_limit='10MB'

# we can group by 9K integers (fits into one block of 256KB)
statement ok
SELECT i, MIN(i), MAX(i) FROM range(9000) tbl(i) GROUP BY i

# 1M integers is too much -> does not fit into 1MB
statement error
SELECT i, MIN(i), MAX(i) FROM range(1000000) tbl(i) GROUP BY i
----

# we can group by 9K integers a bunch of times -> memory should be released between queries
loop i 0 10

statement ok
SELECT i, MIN(i), MAX(i) FROM range(9000) tbl(i) GROUP BY i

endloop

# set the memory limit back to 2MB again, no more GROUP BY's in this test
statement ok
PRAGMA memory_limit='2MB'

# we can create a single table with 10K integers
statement ok
CREATE TABLE t1 AS SELECT * FROM range(10000) tbl(i)

# we can't create a table with 1M integers: not enough memory!
statement error
CREATE TABLE t2 AS SELECT * FROM range(1000000) tbl(i)
----

# if we drop the table, we can re-use any memory that the table took up (i.e. the memory gets released again)
loop i 0 10

statement ok
DROP TABLE t1;

statement ok
CREATE TABLE t1 AS SELECT * FROM range(10000) tbl(i)

endloop

# same with strings
loop i 0 10

statement ok
DROP TABLE t1;

statement ok
CREATE TABLE t1 AS SELECT i::VARCHAR FROM range(10000) tbl(i)

endloop