Posted: 21 Oct 2015 7:29 EDT Last activity: 22 Oct 2015 5:23 EDT
What is the best practice for updating large volume of Customer data (referencing purpose) in a 24*7 production environment
is there any OOTB activity to update any property (for instance, Table Name) of Database Table instances?
We are interested in change table mapped to an other backup table (same structure) during update process of main table (this update process becomes main table blank for a few seconds).
So our approach to let end users to use data of main table during update process is to copy data in main table to a work table, update instance of Database Table that maps table to referenced class, using work table, udpate data in new table and when process is finished, update again Database Table instance to map to main table.
Our approach is to use a work table during update of main table, so we are thinking on switch table name of Database Table instance, when we switch main table to work table, both tables have similar data, and when we switch work table to main table after update process, new data updated in main table is published for users.
We don´t need to sync back data in work table to main table after the process because this table is only for read purposes, so it won´t change while users interact with it.
So our goal is to avoid time with blank data in main table during update process.
I hope it will give you a correct sense of our need.
So if I understand correctly, you want to use the backup table to run reports and fetch data when the main table is unavailable during updates.
Changing the Data-Admin-DB-Table instance so that the class is mapped to the right backup table for even a small time is a costly operation. This is because we maintain the table information in memory so that we can do the property to column mapping correctly including property types to column types. Also, this change when updated on one node would need to be pulsed (using SystemPulse) to all other nodes as well and that delay could be up to 60 seconds. So depending on how long your update on main table will take, it may not be a good idea to do this at all.
That said, if you still want to do this, you should write an activity which can do an obj-open, modify the table name (property-set) and do an obj-save to change the value. I don't think we have any direct API available.
I'm going to agree with Rajiv that your approach is questionable. What sort of update are you planning on doing to your main table that you'd make it unavailable during a time frame where you are trying to do work? I'm going to assume you are on Pega 7. If you have a split schema, I believe (and this is not my area of expertise, so I'm sure I'm overlooking something. Hopefully someone more knowledgeable will chime in) you can copy your data schema, make your changes and then point your system to the new schema. That would allow you to run uninterrupted and not require creating a custom activity to change the database on the fly.
Alternately, if there is specific data you'll want your read only users to have access to, you may just want to use a Rule-Declare-Index to mirror it in an index table that you could work directly off of while your other table is unavailable.
We have a 4 million records table of customers of our final client, this table is updated daily. This table is used by agents of final users to run strategies and extract best offers for customers.
During daily update, we truncate customers table and insert complete set of customers, and while truncate is done until insert is finished, table is blank. It usually happens at night during non-use window of users, as we currently don´t have 24x7 service, but we are interested in move to 24x7 service so we need customers table available during update..
As we always have backup table of customers during update to recover it quickly it update fails, we are thinking about using this backup table be mapped during update of customers table, and map again customers table when update is finished.
As you said, I'm not sure if my approach (swich table name on table instance) to fulfill my need is the best one, I'm only checking available approaches to choose the one that meets better our need.
I hope it will give you better vision about what we need to do.
On the other hand, I'm not familiarized with options you have described, I'm not going to study them and let you know.
Ah! So you're not talking about a table full of work objects, that simplifies things some. How are you getting data into the Pega Platform for use? Reports? Obj-browse? Direct SQL queries from a Java step? All of the above? Depending on how you are accessing the data, you probably have a few options. Also, changing table names (perhaps via a Java step or something else outside the guardrails... but what you are doing is fairly custom) should be doable.
How do you generate the backup table today? Is that done via scripts in the DB? Couldn't you make the second table, insert directly into it, and then switch the table names once it has completed all from an SQL script? That probably has the fewest moving parts since the Pega Platform would always point to the same customer table. Once you've made the "new" table become the active customer table, you could drop the old one, or truncate it to prepare for the following go 'round. And if something goes wrong with the creation of the table/inserts, you just don't do the rename and work off of the current customer table until things are sorted.
We mainly use this table for Obj-browse and reports.
As you said, we generate backup table by SQL scripts, and you are right about renaming tables is other option to study. The third one I'm currently studying is to change TRUNCATE&INSERT current mode for DELETE&INSERT&COMMIT, but in this case I'm afraid that temp data until commit is done is very large as we are managing 4 million records table with 150 columns.
I will check all options and decide with is the correct one (I'm almost sure that renaming tables will be the best one).
Thanks for your effort to help me, I appreciate it a lot!
How about having 2 classes, one clone of other but mapped to two different tables. and switch the class name for the rules performing obj-browse instead of switching table name, I believe reports wont be problem for this brief period of time even if they keep working on existing live table?