Thread: Re: pgbench with partitioned tables

Re: pgbench with partitioned tables

From
Melanie Plageman
Date:
On Fri, Jan 31, 2025 at 6:32 AM Sergey Tatarintsev
<s.tatarintsev@postgrespro.ru> wrote:
>
> When using manually created partitioned tables for pgbench, an error
> occurred:
> ERROR:  cannot perform COPY FREEZE on a partitioned table.
>
> Currently only pgbench_accounts can be partitioned, all others must be a
> regular tables.
>
> I wrote a patch to disable WITH (FREEZE = ON) when generating data for
> non-regular tables.

Thanks for the patch!

I recommend including a repro when proposing such things. Here's one I made

# pgbench init so all the tables are there
pgbench -i -s 10

# drop pgbench_tellers and recreate it partitioned
psql -f- <<EOF
DROP TABLE IF EXISTS pgbench_tellers;
CREATE TABLE pgbench_tellers (
    tid INT NOT NULL,
    bid INT,
    tbalance INT,
    filler CHAR(84)
) PARTITION BY RANGE (tid);

CREATE TABLE pgbench_tellers_p1
PARTITION OF pgbench_tellers
FOR VALUES FROM (1) TO (50);

CREATE TABLE pgbench_tellers_p2
PARTITION OF pgbench_tellers
FOR VALUES FROM (50) TO (2000);
EOF

# run pgbench init with only the data gen step
pgbench -i -I g -s 10

Personally, I have needed to disable COPY FREEZE during pgbench -i
when benchmarking features related to vacuum's freezing behavior.

Maybe instead of just not using COPY FREEZE on a table if it is
partitioned, we could add new data generation init_steps. Perhaps one
that is client-side data generation (g) but with no freezing? I'm not
really sure what the letter would be (f? making it f, g, and G?).

It seems they did not consider making COPY FREEZE optional when adding
the feature to pgbench [1].

This differs from your patch's behavior but it might still solve your problem?

- Melanie

[1] https://www.postgresql.org/message-id/flat/20210308.143907.2014279678657453983.t-ishii%40gmail.com