mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-21 21:21:22 +08:00
This patch refactors the insert path to use insert triggers instead of a temporary copy table. The copy table previously served as an optimization for big batches where the cost of inserting tuple-by-tuple into chunks was amortized by inserting all tuples for a specific chunk in one insert. However, to avoid deadlocks the tuples also had to inserted in a specific chunk order, requiring adding an index to the copy table. With trigger insertion, tuples are instead collected over a batch into a sorting state, which is sorted in an "after" trigger. This removes the overhead of the copy table and index. It also provides a fast-path for single-tuple batches that avoids doing sorting altogether.
31 lines
654 B
SQL
31 lines
654 B
SQL
\set ON_ERROR_STOP 1
|
|
\set VERBOSITY verbose
|
|
\set SHOW_CONTEXT never
|
|
|
|
\o /dev/null
|
|
\ir include/insert_two_partitions.sql
|
|
\o
|
|
\set ECHO ALL
|
|
|
|
\c single
|
|
\d+ "_timescaledb_internal".*
|
|
|
|
-- Test that renaming hypertable is blocked
|
|
\set ON_ERROR_STOP 0
|
|
ALTER TABLE "testNs" RENAME TO "newname";
|
|
\set ON_ERROR_STOP 1
|
|
|
|
-- Test that renaming ordinary table works
|
|
CREATE TABLE renametable (foo int);
|
|
ALTER TABLE "renametable" RENAME TO "newname";
|
|
SELECT * FROM "newname";
|
|
|
|
SELECT * FROM _timescaledb_catalog.hypertable;
|
|
DROP TABLE "testNs";
|
|
|
|
SELECT * FROM _timescaledb_catalog.hypertable;
|
|
\dt "public".*
|
|
\dt "_timescaledb_catalog".*
|
|
\dt+ "_timescaledb_internal".*
|
|
|