-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathINIT-STEP3-init-pgbench_accounts.sql
48 lines (29 loc) · 1.33 KB
/
INIT-STEP3-init-pgbench_accounts.sql
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
\set QUIET 1
BEGIN;
drop table if exists public.pgbench_accounts;
CREATE TABLE public.pgbench_accounts
as
select generate_series::integer aid, generate_series::integer bid , round((random()*(10-1)+1)::numeric,2) abalance, null filler
from generate_series(1,9999)
;
---
drop table if exists public.pgbench_accounts_part;
CREATE TABLE public.pgbench_accounts_part (
aid integer NOT NULL,
bid integer,
abalance float,
filler character(84),
part_key smallint
)
partition by list (part_key);
create table public.pgbench_accounts_part_00 (like public.pgbench_accounts_part);
create table public.pgbench_accounts_part_01 (like public.pgbench_accounts_part);
create table public.pgbench_accounts_part_02 (like public.pgbench_accounts_part);
alter table public.pgbench_accounts_part attach partition public.pgbench_accounts_part_00 for values in (0);
alter table public.pgbench_accounts_part attach partition public.pgbench_accounts_part_01 for values in (1);
alter table public.pgbench_accounts_part attach partition public.pgbench_accounts_part_02 for values in (2);
insert into public.pgbench_accounts_part (aid, bid, abalance, filler, part_key)
select aid, bid, abalance, filler, aid % 3 as part_key from public.pgbench_accounts;
COMMIT;
\set QUIET 0
select avg(abalance) from public.pgbench_accounts_part;