File: 4-list-table-split.sh

package info (click to toggle)
pgcopydb 0.17-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 30,636 kB
  • sloc: ansic: 217,474; sql: 1,654; sh: 812; makefile: 365; python: 94
file content (59 lines) | stat: -rw-r--r-- 2,094 bytes parent folder | download
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
#! /bin/bash

set -x
set -e

# This script expects the following environment variable(s) to be set:
#
#  - PGCOPYDB_SOURCE_PGURI

# `pgcopydb list table-parts` will use the table-size cache populated in
# `pgcopydb.table_size` in '4-list-table-split.sql'.
#
# The values stored in pgcopydb.table_size cache may not accurate, but the
# pgcopydb commands will make decisions based on the available information in
# the cache.

DIR=/tmp/unit/split
OPTS="--not-consistent --split-tables-larger-than 10kB"

pgcopydb list schema --dir ${DIR} ${OPTS} >/dev/null

# Cached size of table_1 is 100 KB, so this will be split into 10 parts
pgcopydb list table-parts --dir ${DIR} \
    --schema-name "public" --table-name "table_1" \
    --split-tables-larger-than "10 kB" 2>&1

# table_2 is identical to table_1 but with the size of 50 KB, so this will be
# split into 5 parts
pgcopydb list table-parts --dir ${DIR} \
    --schema-name "public" --table-name "table_2" \
    --split-tables-larger-than "10 kB" 2>&1

# table_3 doesn't have size in cache, therefore it will not be split
pgcopydb list table-parts --dir ${DIR} \
    --schema-name "public" --table-name "table_3" \
    --split-tables-larger-than "10 kB" 2>&1

# table_ctid_candidate doesn't have a unique integer, therefore it will be split by ctid
pgcopydb list table-parts --dir ${DIR} \
    --schema-name "public" --table-name "table_ctid_candidate" \
    --split-tables-larger-than "10 kB" 2>&1

# ctid split is disabled, no partitioning will be done
pgcopydb list table-parts --dir ${DIR} \
    --schema-name "public" --table-name "table_ctid_candidate_skip" \
    --split-tables-larger-than "10 kB" \
    --skip-split-by-ctid 2>&1


# Now we will test the limits on the number of parts
DIR=/tmp/unit/split-with-limits
OPTS+=" --split-max-parts 3"

pgcopydb list schema --dir ${DIR} ${OPTS} >/dev/null

# limits on the number of parts will be respected, and we will see 3 parts now
pgcopydb list table-parts --dir ${DIR} \
    --schema-name "public" --table-name "table_1" \
    --split-tables-larger-than "10 kB" --split-max-parts 3 2>&1