Skip to content

Commit ab6e588

Browse files
committed
Move causal column type query inside cache-miss block (OPT-7a)
Move the pg_attribute query for v_causal_column_type from pre-cache section to inside the cache-miss block, eliminating 1 catalog query on every cached temporal_merge call. Analysis showed only this query (of 4 pre-cache queries) could be moved: - PK columns query: Cannot move - used for cache key computation - Causal type query: CAN move - only used inside cache-miss block - Temporal cols queries: Cannot move - determine SQL structure Updated expected output line numbers in 3 test files.
1 parent b00531d commit ab6e588

27 files changed

Lines changed: 1154 additions & 1148 deletions

expected/066_temporal_merge_range_only.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ CALL sql_saga.temporal_merge(
281281
primary_identity_columns => '{id}'::text[]
282282
);
283283
ERROR: Source table "source_boundary" must have either the range column "valid_range" or the component column "<NULL>".
284-
CONTEXT: PL/pgSQL function sql_saga.temporal_merge_plan(regclass,regclass,sql_saga.temporal_merge_mode,name,text[],name,name,sql_saga.temporal_merge_delete_mode,jsonb,text[],boolean,boolean) line 299 at RAISE
284+
CONTEXT: PL/pgSQL function sql_saga.temporal_merge_plan(regclass,regclass,sql_saga.temporal_merge_mode,name,text[],name,name,sql_saga.temporal_merge_delete_mode,jsonb,text[],boolean,boolean) line 294 at RAISE
285285
SQL statement "INSERT INTO temporal_merge_plan
286286
SELECT * FROM sql_saga.temporal_merge_plan(
287287
target_table => temporal_merge.target_table,

expected/088_temporal_merge_source_columns.out

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ CALL sql_saga.temporal_merge(
9191
natural_identity_columns => ARRAY['org_nr_typo']
9292
);
9393
ERROR: lookup_column org_nr_typo does not exist in target table repro.units
94-
CONTEXT: PL/pgSQL function sql_saga.temporal_merge_plan(regclass,regclass,sql_saga.temporal_merge_mode,name,text[],name,name,sql_saga.temporal_merge_delete_mode,jsonb,text[],boolean,boolean) line 498 at RAISE
94+
CONTEXT: PL/pgSQL function sql_saga.temporal_merge_plan(regclass,regclass,sql_saga.temporal_merge_mode,name,text[],name,name,sql_saga.temporal_merge_delete_mode,jsonb,text[],boolean,boolean) line 493 at RAISE
9595
SQL statement "INSERT INTO temporal_merge_plan
9696
SELECT * FROM sql_saga.temporal_merge_plan(
9797
target_table => temporal_merge.target_table,
@@ -121,7 +121,7 @@ CALL sql_saga.temporal_merge(
121121
natural_identity_columns => ARRAY['org_nr_typo']
122122
);
123123
ERROR: Source table "source_with_typo" must have a "valid_range", "valid_until", or "<NULL>" column.
124-
CONTEXT: PL/pgSQL function sql_saga.temporal_merge_plan(regclass,regclass,sql_saga.temporal_merge_mode,name,text[],name,name,sql_saga.temporal_merge_delete_mode,jsonb,text[],boolean,boolean) line 327 at RAISE
124+
CONTEXT: PL/pgSQL function sql_saga.temporal_merge_plan(regclass,regclass,sql_saga.temporal_merge_mode,name,text[],name,name,sql_saga.temporal_merge_delete_mode,jsonb,text[],boolean,boolean) line 322 at RAISE
125125
SQL statement "INSERT INTO temporal_merge_plan
126126
SELECT * FROM sql_saga.temporal_merge_plan(
127127
target_table => temporal_merge.target_table,
@@ -151,7 +151,7 @@ CALL sql_saga.temporal_merge(
151151
natural_identity_columns => ARRAY['org_nr']
152152
);
153153
ERROR: Source table "source_with_id" must have a "valid_range", "valid_until", or "<NULL>" column.
154-
CONTEXT: PL/pgSQL function sql_saga.temporal_merge_plan(regclass,regclass,sql_saga.temporal_merge_mode,name,text[],name,name,sql_saga.temporal_merge_delete_mode,jsonb,text[],boolean,boolean) line 327 at RAISE
154+
CONTEXT: PL/pgSQL function sql_saga.temporal_merge_plan(regclass,regclass,sql_saga.temporal_merge_mode,name,text[],name,name,sql_saga.temporal_merge_delete_mode,jsonb,text[],boolean,boolean) line 322 at RAISE
155155
SQL statement "INSERT INTO temporal_merge_plan
156156
SELECT * FROM sql_saga.temporal_merge_plan(
157157
target_table => temporal_merge.target_table,

expected/091_temporal_merge_error_message_bug.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ CALL sql_saga.temporal_merge(
7373
row_id_column => 'row_id'
7474
);
7575
ERROR: Source table "source_units" must have a "valid_range", "valid_until", or "valid_to" column.
76-
CONTEXT: PL/pgSQL function sql_saga.temporal_merge_plan(regclass,regclass,sql_saga.temporal_merge_mode,name,text[],name,name,sql_saga.temporal_merge_delete_mode,jsonb,text[],boolean,boolean) line 327 at RAISE
76+
CONTEXT: PL/pgSQL function sql_saga.temporal_merge_plan(regclass,regclass,sql_saga.temporal_merge_mode,name,text[],name,name,sql_saga.temporal_merge_delete_mode,jsonb,text[],boolean,boolean) line 322 at RAISE
7777
SQL statement "INSERT INTO temporal_merge_plan
7878
SELECT * FROM sql_saga.temporal_merge_plan(
7979
target_table => temporal_merge.target_table,
@@ -167,7 +167,7 @@ CALL sql_saga.temporal_merge(
167167
mode => 'MERGE_ENTITY_UPSERT'
168168
);
169169
ERROR: Source table "source_units" must have a "valid_range", "valid_until", or "<NULL>" column.
170-
CONTEXT: PL/pgSQL function sql_saga.temporal_merge_plan(regclass,regclass,sql_saga.temporal_merge_mode,name,text[],name,name,sql_saga.temporal_merge_delete_mode,jsonb,text[],boolean,boolean) line 327 at RAISE
170+
CONTEXT: PL/pgSQL function sql_saga.temporal_merge_plan(regclass,regclass,sql_saga.temporal_merge_mode,name,text[],name,name,sql_saga.temporal_merge_delete_mode,jsonb,text[],boolean,boolean) line 322 at RAISE
171171
SQL statement "INSERT INTO temporal_merge_plan
172172
SELECT * FROM sql_saga.temporal_merge_plan(
173173
target_table => temporal_merge.target_table,

expected/performance/100_benchmark_basic_dml_benchmark_monitor.csv

Lines changed: 47 additions & 44 deletions
Large diffs are not rendered by default.
Lines changed: 58 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,79 @@
11
event | row_count | time_from_start | time_from_prev | row_count | rows_per_second
22
----------------------------------------+-----------+-----------------+----------------+-----------+-----------------
33
BEGIN | 0 | 0 ms | | 0 rows |
4-
Parent INSERT (Plain) | 0 | 363 ms | 363 ms | 0 rows |
5-
Parent INSERT (Plain) | 1000 | 382 ms | 19 ms | 1000 rows | ~51728 rows/s
6-
Parent UPDATE Key (Plain) | 0 | 383 ms | 0 ms | 0 rows |
7-
Parent UPDATE Key (Plain) | 1000 | 393 ms | 10 ms | 1000 rows | ~99751 rows/s
8-
Parent UPDATE Non-Key (Plain) | 0 | 393 ms | 0 ms | 0 rows |
9-
Parent UPDATE Non-Key (Plain) | 1000 | 402 ms | 10 ms | 1000 rows | ~103509 rows/s
10-
Parent DELETE (Plain) | 0 | 402 ms | 0 ms | 0 rows |
11-
Parent DELETE (Plain) | 1000 | 403 ms | 1 ms | 1000 rows | ~998004 rows/s
12-
Child INSERT (Plain) | 0 | 403 ms | 0 ms | 0 rows |
13-
Child INSERT (Plain) | 1000 | 417 ms | 13 ms | 1000 rows | ~75924 rows/s
14-
Child UPDATE Key (Plain) | 0 | 417 ms | 0 ms | 0 rows |
15-
Child UPDATE Key (Plain) | 1000 | 425 ms | 8 ms | 1000 rows | ~121212 rows/s
16-
Child UPDATE Non-Key (Plain) | 0 | 425 ms | 0 ms | 0 rows |
17-
Child UPDATE Non-Key (Plain) | 1000 | 433 ms | 8 ms | 1000 rows | ~126103 rows/s
18-
Child DELETE (Plain) | 0 | 433 ms | 0 ms | 0 rows |
19-
Child DELETE (Plain) | 1000 | 434 ms | 1 ms | 1000 rows | ~858369 rows/s
20-
Regular INSERT (Plain) | 0 | 434 ms | 0 ms | 0 rows |
21-
Regular INSERT (Plain) | 1000 | 437 ms | 3 ms | 1000 rows | ~340948 rows/s
22-
Regular UPDATE (Plain) | 0 | 437 ms | 0 ms | 0 rows |
23-
Regular UPDATE (Plain) | 1000 | 440 ms | 3 ms | 1000 rows | ~354736 rows/s
24-
Regular DELETE (Plain) | 0 | 440 ms | 0 ms | 0 rows |
25-
Regular DELETE (Plain) | 1000 | 441 ms | 1 ms | 1000 rows | ~831255 rows/s
26-
Parent INSERT (No Index) | 0 | 1 secs | 781 ms | 0 rows |
27-
Parent INSERT (No Index) | 1000 | 1 secs | 33 ms | 1000 rows | ~30739 rows/s
4+
Parent INSERT (Plain) | 0 | 383 ms | 383 ms | 0 rows |
5+
Parent INSERT (Plain) | 1000 | 404 ms | 20 ms | 1000 rows | ~49222 rows/s
6+
Parent UPDATE Key (Plain) | 0 | 404 ms | 0 ms | 0 rows |
7+
Parent UPDATE Key (Plain) | 1000 | 414 ms | 11 ms | 1000 rows | ~95057 rows/s
8+
Parent UPDATE Non-Key (Plain) | 0 | 414 ms | 0 ms | 0 rows |
9+
Parent UPDATE Non-Key (Plain) | 1000 | 425 ms | 11 ms | 1000 rows | ~94500 rows/s
10+
Parent DELETE (Plain) | 0 | 425 ms | 0 ms | 0 rows |
11+
Parent DELETE (Plain) | 1000 | 426 ms | 1 ms | 1000 rows | ~804505 rows/s
12+
Child INSERT (Plain) | 0 | 426 ms | 0 ms | 0 rows |
13+
Child INSERT (Plain) | 1000 | 439 ms | 13 ms | 1000 rows | ~78734 rows/s
14+
Child UPDATE Key (Plain) | 0 | 439 ms | 0 ms | 0 rows |
15+
Child UPDATE Key (Plain) | 1000 | 448 ms | 9 ms | 1000 rows | ~117206 rows/s
16+
Child UPDATE Non-Key (Plain) | 0 | 448 ms | 0 ms | 0 rows |
17+
Child UPDATE Non-Key (Plain) | 1000 | 457 ms | 9 ms | 1000 rows | ~116117 rows/s
18+
Child DELETE (Plain) | 0 | 457 ms | 0 ms | 0 rows |
19+
Child DELETE (Plain) | 1000 | 458 ms | 1 ms | 1000 rows | ~800000 rows/s
20+
Regular INSERT (Plain) | 0 | 458 ms | 0 ms | 0 rows |
21+
Regular INSERT (Plain) | 1000 | 460 ms | 2 ms | 1000 rows | ~419992 rows/s
22+
Regular UPDATE (Plain) | 0 | 460 ms | 0 ms | 0 rows |
23+
Regular UPDATE (Plain) | 1000 | 463 ms | 3 ms | 1000 rows | ~362582 rows/s
24+
Regular DELETE (Plain) | 0 | 463 ms | 0 ms | 0 rows |
25+
Regular DELETE (Plain) | 1000 | 464 ms | 1 ms | 1000 rows | ~834028 rows/s
26+
Parent INSERT (No Index) | 0 | 1 secs | 794 ms | 0 rows |
27+
Parent INSERT (No Index) | 1000 | 1 secs | 34 ms | 1000 rows | ~29065 rows/s
2828
Parent UPDATE Key (No Index) | 0 | 1 secs | 0 ms | 0 rows |
29-
Parent UPDATE Key (No Index) | 1000 | 2 secs | 915 ms | 1000 rows | ~1092 rows/s
29+
Parent UPDATE Key (No Index) | 1000 | 2 secs | 971 ms | 1000 rows | ~1030 rows/s
3030
Parent UPDATE Non-Key (No Index) | 0 | 2 secs | 0 ms | 0 rows |
31-
Parent UPDATE Non-Key (No Index) | 1000 | 2 secs | 20 ms | 1000 rows | ~49200 rows/s
31+
Parent UPDATE Non-Key (No Index) | 1000 | 2 secs | 22 ms | 1000 rows | ~44833 rows/s
3232
Parent DELETE (No Index) | 0 | 2 secs | 0 ms | 0 rows |
33-
Parent DELETE (No Index) | 1000 | 3 secs | 901 ms | 1000 rows | ~1110 rows/s
33+
Parent DELETE (No Index) | 1000 | 3 secs | 950 ms | 1000 rows | ~1052 rows/s
3434
Parent DELETE (Check Only, No Index) | 0 | 3 secs | 0 ms | 0 rows |
35-
Parent DELETE (Check Only, No Index) | 1000 | 4 secs | 904 ms | 1000 rows | ~1106 rows/s
35+
Parent DELETE (Check Only, No Index) | 1000 | 4 secs | 947 ms | 1000 rows | ~1056 rows/s
3636
Child INSERT (No Index) | 0 | 4 secs | 0 ms | 0 rows |
37-
Child INSERT (No Index) | 1000 | 4 secs | 35 ms | 1000 rows | ~28593 rows/s
37+
Child INSERT (No Index) | 1000 | 4 secs | 37 ms | 1000 rows | ~27151 rows/s
3838
Child UPDATE Key (No Index) | 0 | 4 secs | 0 ms | 0 rows |
39-
Child UPDATE Key (No Index) | 1000 | 4 secs | 32 ms | 1000 rows | ~31533 rows/s
39+
Child UPDATE Key (No Index) | 1000 | 4 secs | 37 ms | 1000 rows | ~27081 rows/s
4040
Child UPDATE Non-Key (No Index) | 0 | 4 secs | 0 ms | 0 rows |
41-
Child UPDATE Non-Key (No Index) | 1000 | 4 secs | 18 ms | 1000 rows | ~55233 rows/s
41+
Child UPDATE Non-Key (No Index) | 1000 | 4 secs | 19 ms | 1000 rows | ~52334 rows/s
4242
Child DELETE (No Index) | 0 | 4 secs | 0 ms | 0 rows |
43-
Child DELETE (No Index) | 1000 | 4 secs | 1 ms | 1000 rows | ~980392 rows/s
43+
Child DELETE (No Index) | 1000 | 4 secs | 1 ms | 1000 rows | ~819672 rows/s
4444
Regular INSERT (No Index) | 0 | 4 secs | 0 ms | 0 rows |
45-
Regular INSERT (No Index) | 1000 | 4 secs | 11 ms | 1000 rows | ~88992 rows/s
46-
Regular UPDATE (No Index) | 0 | 4 secs | 0 ms | 0 rows |
47-
Regular UPDATE (No Index) | 1000 | 4 secs | 1 ms | 1000 rows | ~0 rows/s
48-
Regular DELETE (No Index) | 0 | 4 secs | 0 ms | 0 rows |
45+
Regular INSERT (No Index) | 1000 | 4 secs | 13 ms | 1000 rows | ~77274 rows/s
46+
Regular UPDATE (No Index) | 0 | 4 secs | 2 ms | 0 rows |
47+
Regular UPDATE (No Index) | 1000 | 4 secs | 1 ms | 1000 rows | ~901713 rows/s
48+
Regular DELETE (No Index) | 0 | 4 secs | 1 ms | 0 rows |
4949
Regular DELETE (No Index) | 1000 | 4 secs | 1 ms | 1000 rows | ~0 rows/s
50-
Parent INSERT (With Index) | 0 | 4 secs | 5 ms | 0 rows |
51-
Parent INSERT (With Index) | 1000 | 4 secs | 33 ms | 1000 rows | ~30320 rows/s
50+
Parent INSERT (With Index) | 0 | 4 secs | 6 ms | 0 rows |
51+
Parent INSERT (With Index) | 1000 | 4 secs | 36 ms | 1000 rows | ~27938 rows/s
5252
Parent UPDATE Key (With Index) | 0 | 4 secs | 0 ms | 0 rows |
53-
Parent UPDATE Key (With Index) | 1000 | 4 secs | 50 ms | 1000 rows | ~19820 rows/s
53+
Parent UPDATE Key (With Index) | 1000 | 4 secs | 53 ms | 1000 rows | ~19005 rows/s
5454
Parent UPDATE Non-Key (With Index) | 0 | 4 secs | 0 ms | 0 rows |
55-
Parent UPDATE Non-Key (With Index) | 1000 | 4 secs | 24 ms | 1000 rows | ~42303 rows/s
55+
Parent UPDATE Non-Key (With Index) | 1000 | 4 secs | 24 ms | 1000 rows | ~41338 rows/s
5656
Parent DELETE (With Index) | 0 | 4 secs | 0 ms | 0 rows |
57-
Parent DELETE (With Index) | 1000 | 4 secs | 15 ms | 1000 rows | ~65950 rows/s
57+
Parent DELETE (With Index) | 1000 | 4 secs | 15 ms | 1000 rows | ~65108 rows/s
5858
Parent DELETE (Check Only, With Index) | 0 | 4 secs | 0 ms | 0 rows |
59-
Parent DELETE (Check Only, With Index) | 1000 | 4 secs | 15 ms | 1000 rows | ~66221 rows/s
59+
Parent DELETE (Check Only, With Index) | 1000 | 4 secs | 16 ms | 1000 rows | ~64437 rows/s
6060
Child INSERT (With Index) | 0 | 4 secs | 0 ms | 0 rows |
61-
Child INSERT (With Index) | 1000 | 4 secs | 40 ms | 1000 rows | ~25181 rows/s
61+
Child INSERT (With Index) | 1000 | 4 secs | 42 ms | 1000 rows | ~23856 rows/s
6262
Child UPDATE Key (With Index) | 0 | 4 secs | 0 ms | 0 rows |
63-
Child UPDATE Key (With Index) | 1000 | 4 secs | 39 ms | 1000 rows | ~25603 rows/s
64-
Child UPDATE Non-Key (With Index) | 0 | 4 secs | 0 ms | 0 rows |
65-
Child UPDATE Non-Key (With Index) | 1000 | 4 secs | 22 ms | 1000 rows | ~45171 rows/s
66-
Child DELETE (With Index) | 0 | 4 secs | 0 ms | 0 rows |
67-
Child DELETE (With Index) | 1000 | 4 secs | 1 ms | 1000 rows | ~993049 rows/s
68-
Regular INSERT (With Index) | 0 | 4 secs | 0 ms | 0 rows |
69-
Regular INSERT (With Index) | 1000 | 4 secs | 13 ms | 1000 rows | ~77574 rows/s
70-
Regular UPDATE (With Index) | 0 | 4 secs | 0 ms | 0 rows |
71-
Regular UPDATE (With Index) | 1000 | 4 secs | 1 ms | 1000 rows | ~997009 rows/s
72-
Regular DELETE (With Index) | 0 | 4 secs | 0 ms | 0 rows |
73-
Regular DELETE (With Index) | 1000 | 4 secs | 1 ms | 1000 rows | ~0 rows/s
74-
temporal_merge Parent (With Index) | 0 | 4 secs | 63 ms | 0 rows |
75-
temporal_merge Parent (With Index) | 1000 | 5 secs | 198 ms | 1000 rows | ~5056 rows/s
76-
temporal_merge Child (With Index) | 0 | 5 secs | 158 ms | 0 rows |
77-
temporal_merge Child (With Index) | 1000 | 5 secs | 215 ms | 1000 rows | ~4657 rows/s
63+
Child UPDATE Key (With Index) | 1000 | 5 secs | 41 ms | 1000 rows | ~24458 rows/s
64+
Child UPDATE Non-Key (With Index) | 0 | 5 secs | 0 ms | 0 rows |
65+
Child UPDATE Non-Key (With Index) | 1000 | 5 secs | 24 ms | 1000 rows | ~42299 rows/s
66+
Child DELETE (With Index) | 0 | 5 secs | 0 ms | 0 rows |
67+
Child DELETE (With Index) | 1000 | 5 secs | 2 ms | 1000 rows | ~649351 rows/s
68+
Regular INSERT (With Index) | 0 | 5 secs | 0 ms | 0 rows |
69+
Regular INSERT (With Index) | 1000 | 5 secs | 13 ms | 1000 rows | ~78995 rows/s
70+
Regular UPDATE (With Index) | 0 | 5 secs | 0 ms | 0 rows |
71+
Regular UPDATE (With Index) | 1000 | 5 secs | 4 ms | 1000 rows | ~245278 rows/s
72+
Regular DELETE (With Index) | 0 | 5 secs | 0 ms | 0 rows |
73+
Regular DELETE (With Index) | 1000 | 5 secs | 1 ms | 1000 rows | ~0 rows/s
74+
temporal_merge Parent (With Index) | 0 | 5 secs | 63 ms | 0 rows |
75+
temporal_merge Parent (With Index) | 1000 | 5 secs | 207 ms | 1000 rows | ~4822 rows/s
76+
temporal_merge Child (With Index) | 0 | 5 secs | 168 ms | 0 rows |
77+
temporal_merge Child (With Index) | 1000 | 5 secs | 206 ms | 1000 rows | ~4865 rows/s
7878
(75 rows)
7979

0 commit comments

Comments
 (0)