From c60f5a7f88ea180eda97952db55f7c7e384d6e23 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Thu, 29 Oct 2015 19:32:15 -0500 Subject: [PATCH] IDEMPIERE-2811 Each Record should have a primary key - M_ProductPrice / tested in a real migration with 300K records and it was extremely slow, changed the scripts for speed --- .../oracle/201510160847_IDEMPIERE-2811.sql | 9 ++++++++- .../postgresql/201510160847_IDEMPIERE-2811.sql | 18 +++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/migration/i2.1z/oracle/201510160847_IDEMPIERE-2811.sql b/migration/i2.1z/oracle/201510160847_IDEMPIERE-2811.sql index d73b7e6ca4..227ce2c5f8 100644 --- a/migration/i2.1z/oracle/201510160847_IDEMPIERE-2811.sql +++ b/migration/i2.1z/oracle/201510160847_IDEMPIERE-2811.sql @@ -112,9 +112,16 @@ update m_productprice set m_productprice_id=200085 where m_productprice_uu='ecef --CHUCK added here --set the values for the keys -update m_productprice set m_productprice_id = nextIdFunc(165,'N') where m_productprice_id is null; +-- !! too slow without native sequences !! -- update m_productprice set m_productprice_id = nextIdFunc(165,'N') where m_productprice_id is null; --165 = select ad_sequence_id from ad_sequence where name = 'M_ProductPrice' and istableID='Y' +update m_productprice set +m_productprice_id=rownum+999999 +where m_productprice_id is null +; +-- for native sequences is also updated using processes_post_migration/oracle/03_update_sequences.sql +update ad_sequence set currentnext=(select max(m_productprice_id) from m_productprice) where ad_sequence_id=165 +; -- Oct 8, 2015 2:07:06 PM CDT ALTER TABLE M_ProductPrice ADD CONSTRAINT M_ProductPrice_Key PRIMARY KEY (M_ProductPrice_ID) diff --git a/migration/i2.1z/postgresql/201510160847_IDEMPIERE-2811.sql b/migration/i2.1z/postgresql/201510160847_IDEMPIERE-2811.sql index e011746044..514fa670e0 100644 --- a/migration/i2.1z/postgresql/201510160847_IDEMPIERE-2811.sql +++ b/migration/i2.1z/postgresql/201510160847_IDEMPIERE-2811.sql @@ -109,8 +109,24 @@ update m_productprice set m_productprice_id=200085 where m_productprice_uu='ecef --Chuck added here --set the values for the keys -update m_productprice set m_productprice_id = nextIdFunc(165,'N') where m_productprice_id is null; +-- !! too slow without native sequences !! -- update m_productprice set m_productprice_id = nextIdFunc(165,'N') where m_productprice_id is null; --165 = select ad_sequence_id from ad_sequence where name = 'M_ProductPrice' and istableID='Y' +update m_productprice +set m_productprice_id=rownum +from ( +SELECT m_pricelist_version_id, m_product_id + , 999999+ROW_NUMBER() OVER (ORDER BY m_pricelist_version_id, m_product_id) AS rownum +FROM + m_productprice +where m_productprice_id is null +) as numbered +WHERE numbered.m_pricelist_version_id=m_productprice.m_pricelist_version_id +and numbered.m_product_id=m_productprice.m_product_id +; + +-- for native sequences is also updated using processes_post_migration/postgresql/03_update_sequences.sql +update ad_sequence set currentnext=(select max(m_productprice_id) from m_productprice) where ad_sequence_id=165 +; -- Oct 8, 2015 2:07:06 PM CDT ALTER TABLE M_ProductPrice ADD CONSTRAINT M_ProductPrice_Key PRIMARY KEY (M_ProductPrice_ID)