summaryrefslogtreecommitdiff
path: root/src/exchangedb/0002-account_merges.sql
diff options
context:
space:
mode:
Diffstat (limited to 'src/exchangedb/0002-account_merges.sql')
-rw-r--r--src/exchangedb/0002-account_merges.sql18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/exchangedb/0002-account_merges.sql b/src/exchangedb/0002-account_merges.sql
index b1995f204..1dd7e5bf0 100644
--- a/src/exchangedb/0002-account_merges.sql
+++ b/src/exchangedb/0002-account_merges.sql
@@ -15,13 +15,13 @@
--
CREATE FUNCTION create_table_account_merges(
- IN partition_suffix VARCHAR DEFAULT NULL
+ IN partition_suffix TEXT DEFAULT NULL
)
RETURNS VOID
LANGUAGE plpgsql
AS $$
DECLARE
- table_name VARCHAR DEFAULT 'account_merges';
+ table_name TEXT DEFAULT 'account_merges';
BEGIN
PERFORM create_partitioned_table(
'CREATE TABLE IF NOT EXISTS %I '
@@ -64,17 +64,23 @@ $$;
CREATE FUNCTION constrain_table_account_merges(
- IN partition_suffix VARCHAR
+ IN partition_suffix TEXT
)
RETURNS VOID
LANGUAGE plpgsql
AS $$
DECLARE
- table_name VARCHAR DEFAULT 'account_merges';
+ table_name TEXT DEFAULT 'account_merges';
BEGIN
table_name = concat_ws('_', table_name, partition_suffix);
- -- FIXME: change to materialized index by reserve_pub!?
+ -- Note: this index *may* be useful in
+ -- pg_get_reserve_history depending on how
+ -- smart the DB is when computing the JOIN.
+ -- Removing it MAY boost performance slightly, at
+ -- the expense of trouble if the "merge_by_reserve"
+ -- query planner goes off the rails. Needs benchmarking
+ -- to be sure.
EXECUTE FORMAT (
'CREATE INDEX ' || table_name || '_by_reserve_pub '
'ON ' || table_name || ' '
@@ -94,7 +100,7 @@ RETURNS VOID
LANGUAGE plpgsql
AS $$
DECLARE
- table_name VARCHAR DEFAULT 'account_merges';
+ table_name TEXT DEFAULT 'account_merges';
BEGIN
EXECUTE FORMAT (
'ALTER TABLE ' || table_name ||