mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Merged HEAD-BUG-FIX (5.0/Cloud) to HEAD (4.3/Cloud)
72007: Merged V4.2-BUG-FIX (4.2.3) to HEAD-BUG-FIX (4.3/Cloud) 71834: Merged V4.1-BUG-FIX (4.1.9) to V4.2-BUG-FIX (4.2.3) 71763: Merged DEV to V4.1-BUG-FIX (4.1.9) 71455: MNT-10067 : Cleanup alf_prop_XXX data Fixed queries, separated the creation of tables. 71491: MNT-10067 : Cleanup alf_prop_XXX data Changes to MySQl script: - Added index to the id column in temp tables. - Removed transaction marks. - Changed the format of temp tables to MyISAM. 71756: MNT-10067 : Cleanup alf_prop_XXX data Implemented the changes to the scripts for all DBs. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@74729 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,9 +1,76 @@
|
|||||||
--BEGIN TXN
|
-- The script intended to clean obsolete properties from alf_prop_xxx tables
|
||||||
|
-- see MNT-10067
|
||||||
|
--
|
||||||
|
-- All the useful properties in alf_prop_root are gathered in temp_prop_root_ref.
|
||||||
|
-- These can be found in alf_audit_app.disabled_paths_id, alf_audit_entry.audit_values_id, alf_prop_unique_ctx.prop1_id
|
||||||
|
-- Then the obsolete ones are put to temp_prop_root_obs and deleted.
|
||||||
|
--
|
||||||
|
-- Afterwards, all the usefull properties in alf_prop_value are gathered in temp_prop_val_ref.
|
||||||
|
-- These can be found in alf_audit_app.app_name_id, alf_audit_entry.audit_user_id, alf_prop_link.key_prop_id, alf_prop_link.key_prop_id,
|
||||||
|
-- alf_prop_unique_ctx.value1_prop_id, alf_prop_unique_ctx.value2_prop_id, alf_prop_unique_ctx.value3_prop_id.
|
||||||
|
-- All of these tables are participating in recording audit. Afterwards the obsolete values in alf_prop_value are deleted.
|
||||||
|
-- Knowing all the ID's gathered in temp_prop_val_obs.long_value with a combination of the properties type in temp_prop_val_obs.persisted_type,
|
||||||
|
-- the rest of the values used in audit can be deleted from alf_prop_string_value, alf_prop_serializable_value, alf_prop_double_value.
|
||||||
|
|
||||||
|
-- create temp tables
|
||||||
|
create table temp_prop_root_ref
|
||||||
|
(
|
||||||
|
id BIGINT NOT NULL,
|
||||||
|
index idx_temp_prop_root_ref_id (id)
|
||||||
|
) ENGINE=MyISAM;
|
||||||
|
create table temp_prop_root_obs
|
||||||
|
(
|
||||||
|
id BIGINT NOT NULL,
|
||||||
|
index idx_temp_prop_root_obs_id (id)
|
||||||
|
) ENGINE=MyISAM;
|
||||||
|
create table temp_prop_val_ref
|
||||||
|
(
|
||||||
|
id BIGINT NOT NULL,
|
||||||
|
index idx_temp_prop_val_ref_id (id)
|
||||||
|
) ENGINE=MyISAM;
|
||||||
|
create table temp_prop_val_obs
|
||||||
|
(
|
||||||
|
id BIGINT NOT NULL,
|
||||||
|
persisted_type TINYINT NOT NULL,
|
||||||
|
long_value BIGINT NOT NULL,
|
||||||
|
index idx_temp_prop_val_obs_id (id),
|
||||||
|
index idx_temp_prop_val_obs_per (persisted_type, id, long_value)
|
||||||
|
) ENGINE=MyISAM;
|
||||||
|
|
||||||
|
create table temp_del_str1
|
||||||
|
(
|
||||||
|
id BIGINT NOT NULL,
|
||||||
|
PRIMARY KEY (id)
|
||||||
|
) ENGINE=MyISAM;
|
||||||
|
create table temp_del_str2
|
||||||
|
(
|
||||||
|
id BIGINT NOT NULL,
|
||||||
|
PRIMARY KEY (id)
|
||||||
|
) ENGINE=MyISAM;
|
||||||
|
create table temp_del_ser1
|
||||||
|
(
|
||||||
|
id BIGINT NOT NULL,
|
||||||
|
PRIMARY KEY (id)
|
||||||
|
) ENGINE=MyISAM;
|
||||||
|
create table temp_del_ser2
|
||||||
|
(
|
||||||
|
id BIGINT NOT NULL,
|
||||||
|
PRIMARY KEY (id)
|
||||||
|
) ENGINE=MyISAM;
|
||||||
|
create table temp_del_double1
|
||||||
|
(
|
||||||
|
id BIGINT NOT NULL,
|
||||||
|
PRIMARY KEY (id)
|
||||||
|
) ENGINE=MyISAM;
|
||||||
|
create table temp_del_double2
|
||||||
|
(
|
||||||
|
id BIGINT NOT NULL,
|
||||||
|
PRIMARY KEY (id)
|
||||||
|
) ENGINE=MyISAM;
|
||||||
|
|
||||||
-- get all active references to alf_prop_root
|
-- get all active references to alf_prop_root
|
||||||
--FOREACH alf_audit_app.id system.upgrade.clean_alf_prop_tables.batchsize
|
--FOREACH alf_audit_app.id system.upgrade.clean_alf_prop_tables.batchsize
|
||||||
create table temp_prop_root_ref as select disabled_paths_id as id from alf_audit_app where id >= ${LOWERBOUND} and id <= ${UPPERBOUND};
|
insert into temp_prop_root_ref select disabled_paths_id as id from alf_audit_app where id >= ${LOWERBOUND} and id <= ${UPPERBOUND};
|
||||||
create index idx_temp_prop_root_ref_id on temp_prop_root_ref(id);
|
|
||||||
--FOREACH alf_audit_entry.audit_values_id system.upgrade.clean_alf_prop_tables.batchsize
|
--FOREACH alf_audit_entry.audit_values_id system.upgrade.clean_alf_prop_tables.batchsize
|
||||||
insert into temp_prop_root_ref select audit_values_id from alf_audit_entry where audit_values_id >= ${LOWERBOUND} and audit_values_id <= ${UPPERBOUND};
|
insert into temp_prop_root_ref select audit_values_id from alf_audit_entry where audit_values_id >= ${LOWERBOUND} and audit_values_id <= ${UPPERBOUND};
|
||||||
--FOREACH alf_prop_unique_ctx.prop1_id system.upgrade.clean_alf_prop_tables.batchsize
|
--FOREACH alf_prop_unique_ctx.prop1_id system.upgrade.clean_alf_prop_tables.batchsize
|
||||||
@@ -11,18 +78,15 @@ insert into temp_prop_root_ref select prop1_id from alf_prop_unique_ctx where pr
|
|||||||
|
|
||||||
-- determine the obsolete entries from alf_prop_root
|
-- determine the obsolete entries from alf_prop_root
|
||||||
--FOREACH alf_prop_root.id system.upgrade.clean_alf_prop_tables.batchsize
|
--FOREACH alf_prop_root.id system.upgrade.clean_alf_prop_tables.batchsize
|
||||||
create table temp_prop_root_abs as select alf_prop_root.id from alf_prop_root left join temp_prop_root_ref on temp_prop_root_ref.id = alf_prop_root.id where temp_prop_root_ref.id is null and alf_prop_root.id >= ${LOWERBOUND} and alf_prop_root.id <= ${UPPERBOUND};
|
insert into temp_prop_root_obs select alf_prop_root.id from alf_prop_root left join temp_prop_root_ref on temp_prop_root_ref.id = alf_prop_root.id where temp_prop_root_ref.id is null and alf_prop_root.id >= ${LOWERBOUND} and alf_prop_root.id <= ${UPPERBOUND};
|
||||||
create index idx_temp_prop_root_abs_id on temp_prop_root_abs(id);
|
|
||||||
|
|
||||||
-- clear alf_prop_root which cascades DELETE to alf_prop_link
|
-- clear alf_prop_root which cascades DELETE to alf_prop_link
|
||||||
--FOREACH temp_prop_root_abs.id system.upgrade.clean_alf_prop_tables.batchsize
|
--FOREACH temp_prop_root_obs.id system.upgrade.clean_alf_prop_tables.batchsize
|
||||||
delete from alf_prop_root where id in (select id from temp_prop_root_abs where id >= ${LOWERBOUND} and id <= ${UPPERBOUND});
|
delete apr from alf_prop_root apr inner join temp_prop_root_obs tpra on apr.id = tpra.id and tpra.id >= ${LOWERBOUND} and tpra.id <= ${UPPERBOUND};
|
||||||
|
|
||||||
-- get all active references to alf_prop_value
|
-- get all active references to alf_prop_value
|
||||||
|
|
||||||
--FOREACH alf_prop_value.id system.upgrade.clean_alf_prop_tables.batchsize
|
--FOREACH alf_prop_value.id system.upgrade.clean_alf_prop_tables.batchsize
|
||||||
create table temp_prop_val_ref as select id from alf_prop_value where id in (select app_name_id from alf_audit_app) and id >= ${LOWERBOUND} and id <= ${UPPERBOUND};
|
insert into temp_prop_val_ref select id from alf_prop_value where id in (select app_name_id from alf_audit_app) and id >= ${LOWERBOUND} and id <= ${UPPERBOUND};
|
||||||
create index idx_temp_prop_val_ref_id on temp_prop_val_ref(id);
|
|
||||||
--FOREACH alf_audit_entry.audit_user_id system.upgrade.clean_alf_prop_tables.batchsize
|
--FOREACH alf_audit_entry.audit_user_id system.upgrade.clean_alf_prop_tables.batchsize
|
||||||
insert into temp_prop_val_ref select audit_user_id from alf_audit_entry where audit_user_id >= ${LOWERBOUND} and audit_user_id <= ${UPPERBOUND};
|
insert into temp_prop_val_ref select audit_user_id from alf_audit_entry where audit_user_id >= ${LOWERBOUND} and audit_user_id <= ${UPPERBOUND};
|
||||||
--FOREACH alf_prop_link.key_prop_id system.upgrade.clean_alf_prop_tables.batchsize
|
--FOREACH alf_prop_link.key_prop_id system.upgrade.clean_alf_prop_tables.batchsize
|
||||||
@@ -38,27 +102,45 @@ insert into temp_prop_val_ref select value3_prop_id from alf_prop_unique_ctx whe
|
|||||||
|
|
||||||
-- determine the obsolete entries from alf_prop_value
|
-- determine the obsolete entries from alf_prop_value
|
||||||
--FOREACH alf_prop_value.id system.upgrade.clean_alf_prop_tables.batchsize
|
--FOREACH alf_prop_value.id system.upgrade.clean_alf_prop_tables.batchsize
|
||||||
create table temp_prop_val_abs as select apv.id, apv.persisted_type, apv.long_value from alf_prop_value apv left join temp_prop_val_ref on (apv.id = temp_prop_val_ref.id) where temp_prop_val_ref.id is null and apv.id >= ${LOWERBOUND} and apv.id <= ${UPPERBOUND};
|
insert into temp_prop_val_obs select apv.id, apv.persisted_type, apv.long_value from alf_prop_value apv left join temp_prop_val_ref on (apv.id = temp_prop_val_ref.id) where temp_prop_val_ref.id is null and apv.id >= ${LOWERBOUND} and apv.id <= ${UPPERBOUND};
|
||||||
create index idx_temp_prop_val_abs_id on temp_prop_val_abs(id);
|
|
||||||
create index idx_temp_prop_val_abs_per on temp_prop_val_abs(persisted_type, id, long_value);
|
|
||||||
|
|
||||||
-- clear the obsolete entries
|
-- clear the obsolete entries
|
||||||
--FOREACH temp_prop_val_abs.id system.upgrade.clean_alf_prop_tables.batchsize
|
--FOREACH temp_prop_val_obs.id system.upgrade.clean_alf_prop_tables.batchsize
|
||||||
delete from alf_prop_value where id in (select id from temp_prop_val_abs where id >= ${LOWERBOUND} and id <= ${UPPERBOUND});
|
delete apv from alf_prop_value apv inner join temp_prop_val_obs tpva on apv.id = tpva.id and tpva.id >= ${LOWERBOUND} and tpva.id <= ${UPPERBOUND};
|
||||||
|
|
||||||
-- find and clear obsoleted string values
|
-- find and clear obsoleted string values
|
||||||
create table temp_del_str as select temp_prop_val_abs.long_value as string_id from temp_prop_val_abs left join alf_prop_value apv on (apv.id = temp_prop_val_abs.id) where temp_prop_val_abs.persisted_type in (3,5,6) and apv.id is null;
|
-- find the strings already deleted
|
||||||
--FOREACH temp_del_str.string_id system.upgrade.clean_alf_prop_tables.batchsize
|
insert into temp_del_str1 select pva.long_value from temp_prop_val_obs pva where pva.persisted_type in (3, 5, 6);
|
||||||
delete from alf_prop_string_value where id in (select id from temp_del_str where id >= ${LOWERBOUND} and id <= ${UPPERBOUND});
|
--FOREACH temp_del_str1.id system.upgrade.clean_alf_prop_tables.batchsize
|
||||||
|
delete aps from alf_prop_string_value aps inner join temp_del_str1 tds on aps.id = tds.id and tds.id >= ${LOWERBOUND} and tds.id <= ${UPPERBOUND};
|
||||||
|
|
||||||
|
-- or added only to the alf_prop_string_value
|
||||||
|
-- disabled, as it is an edge case and the query is rather slow, see MNT-10067
|
||||||
|
-- FOREACH alf_prop_string_value.id system.upgrade.clean_alf_prop_tables.batchsize
|
||||||
|
-- insert into temp_del_str2 select aps.id from alf_prop_string_value aps left join alf_prop_value apv on apv.long_value = aps.id and apv.persisted_type in (3, 5, 6) where apv.id is null and aps.id >= ${LOWERBOUND} and aps.id <= ${UPPERBOUND};
|
||||||
|
-- FOREACH temp_del_str2.id system.upgrade.clean_alf_prop_tables.batchsize
|
||||||
|
-- delete aps from alf_prop_string_value aps inner join temp_del_str2 tds on aps.id = tds.id and tds.id >= ${LOWERBOUND} and tds.id <= ${UPPERBOUND};
|
||||||
|
|
||||||
-- find and clear obsoleted serialized values
|
-- find and clear obsoleted serialized values
|
||||||
create table temp_del_ser as select temp_prop_val_abs.long_value as string_id from temp_prop_val_abs left join alf_prop_value apv on (apv.id = temp_prop_val_abs.id) where temp_prop_val_abs.persisted_type = 4 and apv.id is null;
|
-- find the serialized values already deleted
|
||||||
--FOREACH temp_del_ser.string_id system.upgrade.clean_alf_prop_tables.batchsize
|
insert into temp_del_ser1 select pva.long_value from temp_prop_val_obs pva where pva.persisted_type = 4;
|
||||||
delete from alf_prop_serializable_value where id in (select id from temp_del_ser where id >= ${LOWERBOUND} and id <= ${UPPERBOUND});
|
--FOREACH temp_del_ser1.id system.upgrade.clean_alf_prop_tables.batchsize
|
||||||
|
delete aps from alf_prop_serializable_value aps inner join temp_del_ser1 tds on aps.id = tds.id and tds.id >= ${LOWERBOUND} and tds.id <= ${UPPERBOUND};
|
||||||
|
|
||||||
|
-- disabled, as it is an edge case and the query is rather slow, see MNT-10067
|
||||||
|
-- FOREACH alf_prop_serializable_value.id system.upgrade.clean_alf_prop_tables.batchsize
|
||||||
|
-- insert into temp_del_ser2 select aps.id from alf_prop_serializable_value aps left join alf_prop_value apv on apv.long_value = aps.id and apv.persisted_type = 4 where apv.id is null and aps.id >= ${LOWERBOUND} and aps.id <= ${UPPERBOUND};
|
||||||
|
-- FOREACH temp_del_ser2.id system.upgrade.clean_alf_prop_tables.batchsize
|
||||||
|
-- delete aps from alf_prop_serializable_value aps inner join temp_del_ser2 tds on aps.id = tds.id and tds.id >= ${LOWERBOUND} and tds.id <= ${UPPERBOUND};
|
||||||
|
|
||||||
-- find and clear obsoleted double values
|
-- find and clear obsoleted double values
|
||||||
create table temp_del_double as select temp_prop_val_abs.long_value as string_id from temp_prop_val_abs left join alf_prop_value apv on (apv.id = temp_prop_val_abs.id) where temp_prop_val_abs.persisted_type = 2 and apv.id is null;
|
-- find the double values already deleted
|
||||||
--FOREACH temp_del_double.string_id system.upgrade.clean_alf_prop_tables.batchsize
|
insert into temp_del_double1 select pva.long_value from temp_prop_val_obs pva where pva.persisted_type = 2;
|
||||||
delete from alf_prop_double_value where id in (select id from temp_del_double where id >= ${LOWERBOUND} and id <= ${UPPERBOUND});
|
--FOREACH temp_del_double1.id system.upgrade.clean_alf_prop_tables.batchsize
|
||||||
|
delete apd from alf_prop_double_value apd inner join temp_del_double1 tdd on apd.id = tdd.id and tdd.id >= ${LOWERBOUND} and tdd.id <= ${UPPERBOUND};
|
||||||
|
|
||||||
--END TXN
|
-- disabled, as it is an edge case and the query is rather slow, see MNT-10067
|
||||||
|
-- FOREACH alf_prop_double_value.id system.upgrade.clean_alf_prop_tables.batchsize
|
||||||
|
-- insert into temp_del_double2 select apd.id from alf_prop_double_value apd left join alf_prop_value apv on apv.long_value = apd.id and apv.persisted_type = 2 where apv.id is null and apd.id >= ${LOWERBOUND} and apd.id <= ${UPPERBOUND};
|
||||||
|
-- FOREACH temp_del_double2.id system.upgrade.clean_alf_prop_tables.batchsize
|
||||||
|
-- delete apd from alf_prop_double_value apd inner join temp_del_double2 tdd on apd.id = tdd.id and tdd.id >= ${LOWERBOUND} and tdd.id <= ${UPPERBOUND};
|
||||||
|
@@ -2,11 +2,14 @@
|
|||||||
|
|
||||||
-- cleanup temporary structures
|
-- cleanup temporary structures
|
||||||
drop table temp_prop_root_ref; --(optional)
|
drop table temp_prop_root_ref; --(optional)
|
||||||
drop table temp_prop_root_abs; --(optional)
|
drop table temp_prop_root_obs; --(optional)
|
||||||
drop table temp_prop_val_ref; --(optional)
|
drop table temp_prop_val_ref; --(optional)
|
||||||
drop table temp_prop_val_abs; --(optional)
|
drop table temp_prop_val_obs; --(optional)
|
||||||
drop table temp_del_str; --(optional)
|
drop table temp_del_str1; --(optional)
|
||||||
drop table temp_del_ser; --(optional)
|
drop table temp_del_str2; --(optional)
|
||||||
drop table temp_del_double; --(optional)
|
drop table temp_del_ser1; --(optional)
|
||||||
|
drop table temp_del_ser2; --(optional)
|
||||||
|
drop table temp_del_double1; --(optional)
|
||||||
|
drop table temp_del_double2; --(optional)
|
||||||
|
|
||||||
--END TXN
|
--END TXN
|
@@ -1,9 +1,77 @@
|
|||||||
|
-- The script intended to clean obsolete properties from alf_prop_xxx tables
|
||||||
|
-- see MNT-10067
|
||||||
|
--
|
||||||
|
-- All the useful properties in alf_prop_root are gathered in temp_prop_root_ref.
|
||||||
|
-- These can be found in alf_audit_app.disabled_paths_id, alf_audit_entry.audit_values_id, alf_prop_unique_ctx.prop1_id
|
||||||
|
-- Then the obsolete ones are put to temp_prop_root_obs and deleted.
|
||||||
|
--
|
||||||
|
-- Afterwards, all the usefull properties in alf_prop_value are gathered in temp_prop_val_ref.
|
||||||
|
-- These can be found in alf_audit_app.app_name_id, alf_audit_entry.audit_user_id, alf_prop_link.key_prop_id, alf_prop_link.key_prop_id,
|
||||||
|
-- alf_prop_unique_ctx.value1_prop_id, alf_prop_unique_ctx.value2_prop_id, alf_prop_unique_ctx.value3_prop_id.
|
||||||
|
-- All of these tables are participating in recording audit. Afterwards the obsolete values in alf_prop_value are deleted.
|
||||||
|
-- Knowing all the ID's gathered in temp_prop_val_obs.long_value with a combination of the properties type in temp_prop_val_obs.persisted_type,
|
||||||
|
-- the rest of the values used in audit can be deleted from alf_prop_string_value, alf_prop_serializable_value, alf_prop_double_value.
|
||||||
|
|
||||||
|
-- create temp tables
|
||||||
--BEGIN TXN
|
--BEGIN TXN
|
||||||
|
create table temp_prop_root_ref
|
||||||
|
(
|
||||||
|
id INT8 NOT NULL
|
||||||
|
);
|
||||||
|
CREATE INDEX idx_temp_prop_root_ref_id ON temp_prop_root_ref(id);
|
||||||
|
create table temp_prop_root_obs
|
||||||
|
(
|
||||||
|
id INT8 NOT NULL
|
||||||
|
);
|
||||||
|
CREATE INDEX idx_temp_prop_root_obs_id ON temp_prop_root_obs(id);
|
||||||
|
create table temp_prop_val_ref
|
||||||
|
(
|
||||||
|
id INT8 NOT NULL
|
||||||
|
);
|
||||||
|
CREATE INDEX idx_temp_prop_val_ref_id ON temp_prop_val_ref(id);
|
||||||
|
create table temp_prop_val_obs
|
||||||
|
(
|
||||||
|
id INT8 NOT NULL,
|
||||||
|
persisted_type INT2 NOT NULL,
|
||||||
|
long_value INT8 NOT NULL
|
||||||
|
);
|
||||||
|
CREATE INDEX idx_temp_prop_val_obs_id ON temp_prop_val_obs(id);
|
||||||
|
CREATE INDEX idx_temp_prop_val_obs_per ON temp_prop_val_obs(persisted_type, id, long_value);
|
||||||
|
|
||||||
|
create table temp_del_str1
|
||||||
|
(
|
||||||
|
id INT8 NOT NULL,
|
||||||
|
PRIMARY KEY (id)
|
||||||
|
);
|
||||||
|
create table temp_del_str2
|
||||||
|
(
|
||||||
|
id INT8 NOT NULL,
|
||||||
|
PRIMARY KEY (id)
|
||||||
|
);
|
||||||
|
create table temp_del_ser1
|
||||||
|
(
|
||||||
|
id INT8 NOT NULL,
|
||||||
|
PRIMARY KEY (id)
|
||||||
|
);
|
||||||
|
create table temp_del_ser2
|
||||||
|
(
|
||||||
|
id INT8 NOT NULL,
|
||||||
|
PRIMARY KEY (id)
|
||||||
|
);
|
||||||
|
create table temp_del_double1
|
||||||
|
(
|
||||||
|
id INT8 NOT NULL,
|
||||||
|
PRIMARY KEY (id)
|
||||||
|
);
|
||||||
|
create table temp_del_double2
|
||||||
|
(
|
||||||
|
id INT8 NOT NULL,
|
||||||
|
PRIMARY KEY (id)
|
||||||
|
);
|
||||||
|
|
||||||
-- get all active references to alf_prop_root
|
-- get all active references to alf_prop_root
|
||||||
--FOREACH alf_audit_app.id system.upgrade.clean_alf_prop_tables.batchsize
|
--FOREACH alf_audit_app.id system.upgrade.clean_alf_prop_tables.batchsize
|
||||||
create temp table temp_prop_root_ref as select disabled_paths_id as id from alf_audit_app where id >= ${LOWERBOUND} and id <= ${UPPERBOUND};
|
insert into temp_prop_root_ref select disabled_paths_id as id from alf_audit_app where id >= ${LOWERBOUND} and id <= ${UPPERBOUND};
|
||||||
create index idx_temp_prop_root_ref_id on temp_prop_root_ref(id);
|
|
||||||
--FOREACH alf_audit_entry.audit_values_id system.upgrade.clean_alf_prop_tables.batchsize
|
--FOREACH alf_audit_entry.audit_values_id system.upgrade.clean_alf_prop_tables.batchsize
|
||||||
insert into temp_prop_root_ref select audit_values_id from alf_audit_entry where audit_values_id >= ${LOWERBOUND} and audit_values_id <= ${UPPERBOUND};
|
insert into temp_prop_root_ref select audit_values_id from alf_audit_entry where audit_values_id >= ${LOWERBOUND} and audit_values_id <= ${UPPERBOUND};
|
||||||
--FOREACH alf_prop_unique_ctx.prop1_id system.upgrade.clean_alf_prop_tables.batchsize
|
--FOREACH alf_prop_unique_ctx.prop1_id system.upgrade.clean_alf_prop_tables.batchsize
|
||||||
@@ -11,17 +79,15 @@ insert into temp_prop_root_ref select prop1_id from alf_prop_unique_ctx where pr
|
|||||||
|
|
||||||
-- determine the obsolete entries from alf_prop_root
|
-- determine the obsolete entries from alf_prop_root
|
||||||
--FOREACH alf_prop_root.id system.upgrade.clean_alf_prop_tables.batchsize
|
--FOREACH alf_prop_root.id system.upgrade.clean_alf_prop_tables.batchsize
|
||||||
create temp table temp_prop_root_abs as select alf_prop_root.id from alf_prop_root left join temp_prop_root_ref on temp_prop_root_ref.id = alf_prop_root.id where temp_prop_root_ref.id is null and alf_prop_root.id >= ${LOWERBOUND} and alf_prop_root.id <= ${UPPERBOUND};
|
insert into temp_prop_root_obs select alf_prop_root.id from alf_prop_root left join temp_prop_root_ref on temp_prop_root_ref.id = alf_prop_root.id where temp_prop_root_ref.id is null and alf_prop_root.id >= ${LOWERBOUND} and alf_prop_root.id <= ${UPPERBOUND};
|
||||||
create index idx_temp_prop_root_abs_id on temp_prop_root_abs(id);
|
|
||||||
|
|
||||||
-- clear alf_prop_root which cascades DELETE to alf_prop_link
|
-- clear alf_prop_root which cascades DELETE to alf_prop_link
|
||||||
--FOREACH temp_prop_root_abs.id system.upgrade.clean_alf_prop_tables.batchsize
|
--FOREACH temp_prop_root_obs.id system.upgrade.clean_alf_prop_tables.batchsize
|
||||||
delete from alf_prop_root where id in (select id from temp_prop_root_abs where id >= ${LOWERBOUND} and id <= ${UPPERBOUND});
|
delete from alf_prop_root apr using temp_prop_root_obs tpra where apr.id = tpra.id and tpra.id >= ${LOWERBOUND} and tpra.id <= ${UPPERBOUND};
|
||||||
|
|
||||||
-- get all active references to alf_prop_value
|
-- get all active references to alf_prop_value
|
||||||
--FOREACH alf_prop_value.id system.upgrade.clean_alf_prop_tables.batchsize
|
--FOREACH alf_prop_value.id system.upgrade.clean_alf_prop_tables.batchsize
|
||||||
create temp table temp_prop_val_ref as select id from alf_prop_value where id in (select app_name_id from alf_audit_app) and id >= ${LOWERBOUND} and id <= ${UPPERBOUND};
|
insert into temp_prop_val_ref select id from alf_prop_value where id in (select app_name_id from alf_audit_app) and id >= ${LOWERBOUND} and id <= ${UPPERBOUND};
|
||||||
create index idx_temp_prop_val_ref_id on temp_prop_val_ref(id);
|
|
||||||
--FOREACH alf_audit_entry.audit_user_id system.upgrade.clean_alf_prop_tables.batchsize
|
--FOREACH alf_audit_entry.audit_user_id system.upgrade.clean_alf_prop_tables.batchsize
|
||||||
insert into temp_prop_val_ref select audit_user_id from alf_audit_entry where audit_user_id >= ${LOWERBOUND} and audit_user_id <= ${UPPERBOUND};
|
insert into temp_prop_val_ref select audit_user_id from alf_audit_entry where audit_user_id >= ${LOWERBOUND} and audit_user_id <= ${UPPERBOUND};
|
||||||
--FOREACH alf_prop_link.key_prop_id system.upgrade.clean_alf_prop_tables.batchsize
|
--FOREACH alf_prop_link.key_prop_id system.upgrade.clean_alf_prop_tables.batchsize
|
||||||
@@ -37,27 +103,47 @@ insert into temp_prop_val_ref select value3_prop_id from alf_prop_unique_ctx whe
|
|||||||
|
|
||||||
-- determine the obsolete entries from alf_prop_value
|
-- determine the obsolete entries from alf_prop_value
|
||||||
--FOREACH alf_prop_value.id system.upgrade.clean_alf_prop_tables.batchsize
|
--FOREACH alf_prop_value.id system.upgrade.clean_alf_prop_tables.batchsize
|
||||||
create temp table temp_prop_val_abs as select apv.id, apv.persisted_type, apv.long_value from alf_prop_value apv left join temp_prop_val_ref on (apv.id = temp_prop_val_ref.id) where temp_prop_val_ref.id is null and apv.id >= ${LOWERBOUND} and apv.id <= ${UPPERBOUND};
|
insert into temp_prop_val_obs select apv.id, apv.persisted_type, apv.long_value from alf_prop_value apv left join temp_prop_val_ref on (apv.id = temp_prop_val_ref.id) where temp_prop_val_ref.id is null and apv.id >= ${LOWERBOUND} and apv.id <= ${UPPERBOUND};
|
||||||
create index idx_temp_prop_val_abs_id on temp_prop_val_abs(id);
|
|
||||||
create index idx_temp_prop_val_abs_per on temp_prop_val_abs(persisted_type, id, long_value);
|
|
||||||
|
|
||||||
-- clear the obsolete entries
|
-- clear the obsolete entries
|
||||||
--FOREACH temp_prop_val_abs.id system.upgrade.clean_alf_prop_tables.batchsize
|
--FOREACH temp_prop_val_obs.id system.upgrade.clean_alf_prop_tables.batchsize
|
||||||
delete from alf_prop_value where id in (select id from temp_prop_val_abs where id >= ${LOWERBOUND} and id <= ${UPPERBOUND});
|
delete from alf_prop_value apv using temp_prop_val_obs tpva where apv.id = tpva.id and tpva.id >= ${LOWERBOUND} and tpva.id <= ${UPPERBOUND};
|
||||||
|
|
||||||
-- find and clear obsoleted string values
|
-- find and clear obsoleted string values
|
||||||
create table temp_del_str as select temp_prop_val_abs.long_value as string_id from temp_prop_val_abs left join alf_prop_value apv on (apv.id = temp_prop_val_abs.id) where temp_prop_val_abs.persisted_type in (3,5,6) and apv.id is null;
|
-- find the strings already deleted
|
||||||
--FOREACH temp_del_str.string_id system.upgrade.clean_alf_prop_tables.batchsize
|
insert into temp_del_str1 select pva.long_value from temp_prop_val_obs pva where pva.persisted_type in (3, 5, 6);
|
||||||
delete from alf_prop_string_value where id in (select id from temp_del_str where id >= ${LOWERBOUND} and id <= ${UPPERBOUND});
|
--FOREACH temp_del_str1.id system.upgrade.clean_alf_prop_tables.batchsize
|
||||||
|
delete from alf_prop_string_value aps using temp_del_str1 tds where aps.id = tds.id and tds.id >= ${LOWERBOUND} and tds.id <= ${UPPERBOUND};
|
||||||
|
|
||||||
|
-- or added only to the alf_prop_string_value
|
||||||
|
-- disabled, as it is an edge case and the query is rather slow, see MNT-10067
|
||||||
|
-- FOREACH alf_prop_string_value.id system.upgrade.clean_alf_prop_tables.batchsize
|
||||||
|
-- insert into temp_del_str2 select aps.id from alf_prop_string_value aps left join alf_prop_value apv on apv.long_value = aps.id and apv.persisted_type in (3, 5, 6) where apv.id is null and aps.id >= ${LOWERBOUND} and aps.id <= ${UPPERBOUND};
|
||||||
|
-- FOREACH temp_del_str2.id system.upgrade.clean_alf_prop_tables.batchsize
|
||||||
|
-- delete from alf_prop_string_value aps using temp_del_str2 tds where aps.id = tds.id and tds.id >= ${LOWERBOUND} and tds.id <= ${UPPERBOUND};
|
||||||
|
|
||||||
-- find and clear obsoleted serialized values
|
-- find and clear obsoleted serialized values
|
||||||
create table temp_del_ser as select temp_prop_val_abs.long_value as string_id from temp_prop_val_abs left join alf_prop_value apv on (apv.id = temp_prop_val_abs.id) where temp_prop_val_abs.persisted_type = 4 and apv.id is null;
|
-- find the serialized values already deleted
|
||||||
--FOREACH temp_del_ser.string_id system.upgrade.clean_alf_prop_tables.batchsize
|
insert into temp_del_ser1 select pva.long_value from temp_prop_val_obs pva where pva.persisted_type = 4;
|
||||||
delete from alf_prop_serializable_value where id in (select id from temp_del_ser where id >= ${LOWERBOUND} and id <= ${UPPERBOUND});
|
--FOREACH temp_del_ser1.id system.upgrade.clean_alf_prop_tables.batchsize
|
||||||
|
delete from alf_prop_serializable_value aps using temp_del_ser1 tds where aps.id = tds.id and tds.id >= ${LOWERBOUND} and tds.id <= ${UPPERBOUND};
|
||||||
|
|
||||||
|
-- disabled, as it is an edge case and the query is rather slow, see MNT-10067
|
||||||
|
-- FOREACH alf_prop_serializable_value.id system.upgrade.clean_alf_prop_tables.batchsize
|
||||||
|
-- insert into temp_del_ser2 select aps.id from alf_prop_serializable_value aps left join alf_prop_value apv on apv.long_value = aps.id and apv.persisted_type = 4 where apv.id is null and aps.id >= ${LOWERBOUND} and aps.id <= ${UPPERBOUND};
|
||||||
|
-- FOREACH temp_del_ser2.id system.upgrade.clean_alf_prop_tables.batchsize
|
||||||
|
-- delete from alf_prop_serializable_value aps using temp_del_ser2 tds where aps.id = tds.id and tds.id >= ${LOWERBOUND} and tds.id <= ${UPPERBOUND};
|
||||||
|
|
||||||
-- find and clear obsoleted double values
|
-- find and clear obsoleted double values
|
||||||
create table temp_del_double as select temp_prop_val_abs.long_value as string_id from temp_prop_val_abs left join alf_prop_value apv on (apv.id = temp_prop_val_abs.id) where temp_prop_val_abs.persisted_type = 2 and apv.id is null;
|
-- find the double values already deleted
|
||||||
--FOREACH temp_del_double.string_id system.upgrade.clean_alf_prop_tables.batchsize
|
insert into temp_del_double1 select pva.long_value from temp_prop_val_obs pva where pva.persisted_type = 2;
|
||||||
delete from alf_prop_double_value where id in (select id from temp_del_double where id >= ${LOWERBOUND} and id <= ${UPPERBOUND});
|
--FOREACH temp_del_double1.id system.upgrade.clean_alf_prop_tables.batchsize
|
||||||
|
delete from alf_prop_double_value apd using temp_del_double1 tdd where apd.id = tdd.id and tdd.id >= ${LOWERBOUND} and tdd.id <= ${UPPERBOUND};
|
||||||
|
|
||||||
|
-- disabled, as it is an edge case and the query is rather slow, see MNT-10067
|
||||||
|
-- FOREACH alf_prop_double_value.id system.upgrade.clean_alf_prop_tables.batchsize
|
||||||
|
-- insert into temp_del_double2 select apd.id from alf_prop_double_value apd left join alf_prop_value apv on apv.long_value = apd.id and apv.persisted_type = 2 where apv.id is null and apd.id >= ${LOWERBOUND} and apd.id <= ${UPPERBOUND};
|
||||||
|
-- FOREACH temp_del_double2.id system.upgrade.clean_alf_prop_tables.batchsize
|
||||||
|
-- delete from alf_prop_double_value apd using temp_del_double2 tdd where apd.id = tdd.id and tdd.id >= ${LOWERBOUND} and tdd.id <= ${UPPERBOUND};
|
||||||
|
|
||||||
--END TXN
|
--END TXN
|
||||||
|
@@ -2,11 +2,14 @@
|
|||||||
|
|
||||||
-- cleanup temporary structures
|
-- cleanup temporary structures
|
||||||
drop table temp_prop_root_ref; --(optional)
|
drop table temp_prop_root_ref; --(optional)
|
||||||
drop table temp_prop_root_abs; --(optional)
|
drop table temp_prop_root_obs; --(optional)
|
||||||
drop table temp_prop_val_ref; --(optional)
|
drop table temp_prop_val_ref; --(optional)
|
||||||
drop table temp_prop_val_abs; --(optional)
|
drop table temp_prop_val_obs; --(optional)
|
||||||
drop table temp_del_str; --(optional)
|
drop table temp_del_str1; --(optional)
|
||||||
drop table temp_del_ser; --(optional)
|
drop table temp_del_str2; --(optional)
|
||||||
drop table temp_del_double; --(optional)
|
drop table temp_del_ser1; --(optional)
|
||||||
|
drop table temp_del_ser2; --(optional)
|
||||||
|
drop table temp_del_double1; --(optional)
|
||||||
|
drop table temp_del_double2; --(optional)
|
||||||
|
|
||||||
--END TXN
|
--END TXN
|
Reference in New Issue
Block a user