40
loading...
This website collects cookies to deliver better user experience
ROWS_PER_TRANSACTION
. To avoid surprises when loading a pg_dump, we also set a default value for it with yb_default_copy_from_rows_per_transaction=1000
. You can set it to 0 do revert to the PostgreSQL behaviour, or set another value depending on your system size and settings.for i in {1..10000000} ; do
echo -e "$i\t$RANDOM$SECONDS\t$SECONDS"
done > /var/tmp/10millions.tsv
du -h /var/tmp/10millions.tsv
for p in {22..0} ; do
psql -c "truncate table demo"
echo PGOPTIONS="-c yb_default_copy_from_rows_per_transaction=$((2** $p))" \
timeout 36000 psql \
-c "show yb_default_copy_from_rows_per_transaction" \
-c "\\timing on" \
-c "\\copy demo from '/var/tmp/10millions.tsv'" \
2>&1
sleep 60
done | ts | tee 10millions.log
awk '/ [0-9]+$/{n=$NF}/Time:/{printf "%10d rows per tx, %5.1f min, %s\n",n,$5/1000/60,$NF}' 10millions.log
4194304 rows per tx, 20.3 min, (20:16.073)
2097152 rows per tx, 15.8 min, (15:49.707)
1048576 rows per tx, 14.3 min, (14:20.843)
524288 rows per tx, 12.0 min, (11:57.360)
262144 rows per tx, 12.3 min, (12:16.458)
131072 rows per tx, 11.4 min, (11:22.775)
65536 rows per tx, 11.4 min, (11:26.464)
32768 rows per tx, 10.7 min, (10:40.638)
16384 rows per tx, 11.4 min, (11:22.026)
8192 rows per tx, 12.0 min, (11:57.187)
4096 rows per tx, 12.2 min, (12:09.036)
2048 rows per tx, 12.8 min, (12:49.271)
1024 rows per tx, 12.7 min, (12:43.371)
512 rows per tx, 12.7 min, (12:39.496)
256 rows per tx, 15.6 min, (15:33.997)
128 rows per tx, 21.9 min, (21:52.231)
64 rows per tx, 29.0 min, (29:00.760)
32 rows per tx, 44.3 min, (44:16.720)
16 rows per tx, 74.8 min, (01:14:46.988)
8 rows per tx, 125.2 min, (02:05:12.894)
4 rows per tx, 205.1 min, (03:25:06.307)
2 rows per tx, 452.1 min, (07:32:04.131)
ysql_non_txn_copy=true
that I mentioned in a previous post, and some other to come in future versions (I'm writing this in YugabyteDB 2.11). But those are reserved for special cases (initial load, migrations, IoT, upserts) where we can bypass some operations without compromising the database. The YSQL INSERT or COPY, with the PostgreSQL syntax and semantic, has to read before writing, in order to detect duplicate key violation. And it has to obey to ACID properties.