<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://sugarclub.sugarcrm.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>How do we reduce storage cost and improve performance by cleaning BPM tables?</title><link>https://sugarclub.sugarcrm.com/explore/help-forums/enterprise-professional/f/enterprise-professional-questions/6711/how-do-we-reduce-storage-cost-and-improve-performance-by-cleaning-bpm-tables</link><description>Hello there, 
 I am working with a Sugar Cloud customer on version 13.0 and they are asking what is the official way to cleanup all BPM SQL tables for old/orphan records. 
 
 They already have a cleanup process for the pmse_inbox SQL table through the</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: How do we reduce storage cost and improve performance by cleaning BPM tables?</title><link>https://sugarclub.sugarcrm.com/thread/30041?ContentTypeID=1</link><pubDate>Fri, 06 Oct 2023 15:38:19 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:75bafa25-59e7-4adf-8e53-fa976f1e58ed</guid><dc:creator>Enes Saridogan</dc:creator><description>&lt;p&gt;Hello&amp;nbsp;&lt;a href="/members/rifa"&gt;Chris Raffle&lt;/a&gt;&amp;nbsp;,&lt;/p&gt;
&lt;p&gt;Thanks a lot for the queries, very useful !&lt;/p&gt;
&lt;p&gt;But a question, when I ran the following query in order to count the number of rows :&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="sql"&gt;SELECT 
    count(*)
FROM 
    pmse_bpm_flow 
WHERE 
    pmse_bpm_flow.cas_id NOT IN (
        SELECT 
            cas_id 
        FROM 
            pmse_inbox 
        WHERE 
            cas_status IN (&amp;#39;COMPLETED&amp;#39;, &amp;#39;TERMINATED&amp;#39;) 
        AND 
            date_modified &amp;lt; DATE_SUB(NOW(), INTERVAL 90 DAY) 
    ) 
OR 
    pmse_bpm_flow.cas_index = 1;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I&amp;#39;m getting the same number of rows than the total of the pmse_bpm_flow table. It tells me that there is nothing to delete at all :/ I have more than 8.8 million rows ...&lt;/p&gt;
&lt;p&gt;Is there anything we should check on this query ? This is very strange, isn&amp;#39;t it ?&lt;/p&gt;
&lt;p&gt;What would be the queries in order to clean up the tables pmse_bpm_form_action and pmse_bpm_thread ?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks a lot and have a nice day !&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Enes&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do we reduce storage cost and improve performance by cleaning BPM tables?</title><link>https://sugarclub.sugarcrm.com/thread/29704?ContentTypeID=1</link><pubDate>Thu, 24 Aug 2023 08:59:00 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:4c7c8e58-fc13-4a35-bd12-de22f829d2c9</guid><dc:creator>Enrico Simonetti</dc:creator><description>&lt;p&gt;Thank you&amp;nbsp;&lt;a href="/members/rifa"&gt;Chris Raffle&lt;/a&gt;&amp;nbsp;!&lt;/p&gt;
&lt;p&gt;I&amp;#39;ll keep the queries in mind. I did have a tool that was doing something similar, but it is no longer working on Sugar 13.0. During my &amp;quot;break&amp;quot;&amp;nbsp;&lt;a href="/dev-club/f/questions-answers/6687/recent-changes-on-entrypoint-php-or-autoloader-or-etc-container-php-or-newer-version-of-ultralite"&gt;something major broke&lt;/a&gt; &lt;span class="emoticon" data-url="https://sugarclub.sugarcrm.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I would have to figure out how pmse_bpm_form_action works and how that table is related to the rest of the bpm tables, as that table is not trimmed in any script/query, and that&amp;#39;s the huge one for the customer.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Cheers!&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do we reduce storage cost and improve performance by cleaning BPM tables?</title><link>https://sugarclub.sugarcrm.com/thread/29700?ContentTypeID=1</link><pubDate>Thu, 24 Aug 2023 05:55:03 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:cae83f7b-18a7-40b4-b0e5-afcb52b54cae</guid><dc:creator>Bud Hartley</dc:creator><description>&lt;p&gt;Wow!&amp;nbsp; I just looked and the option to select &amp;quot;&lt;span&gt;pmse_BpmFlow&amp;quot; isn&amp;#39;t available if I try to create a new Archive. I did this one about a year ago.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;FYI: Chris is correct that deleting a previous process that was scheduled to trigger on create or first update is lost if you delete the history.&amp;nbsp; I have a couple of processes that trigger that way, and the good news is that it wasn&amp;#39;t a problem for me since those processes checked the presence of a value in a field that should have been populated when it triggered.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do we reduce storage cost and improve performance by cleaning BPM tables?</title><link>https://sugarclub.sugarcrm.com/thread/29699?ContentTypeID=1</link><pubDate>Thu, 24 Aug 2023 04:20:55 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:e37244b2-5fbc-4013-a858-4cca0955a0dd</guid><dc:creator>Chris Raffle</dc:creator><description>&lt;p&gt;Hi &lt;a href="/members/enricosimonetti"&gt;Enrico Simonetti&lt;/a&gt;&amp;nbsp;,&lt;/p&gt;
&lt;p&gt;The &amp;#39;pmse_Inbox&amp;#39; selection in the Data Archiver actually has a much broader function in that it cleans other tables like pmse_bpm_flow,&amp;nbsp;pmse_bpm_&lt;span&gt;thread, and pmse_bpm_form. One thing you need to be cautious of with using the Data Archiver for this purpose is if&amp;nbsp;your customer has any SugarBPM definitions with start events set to only trigger once for the lifetime of a record. For this type of start event to work, a record in the pmse_inbox needs to&amp;nbsp;be retained from when it previously was triggered. The Data Archiver currently does not account for this scenario and will remove this history. You can see if your customer has any BPM definitions with these start events by running the following query:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="sql"&gt;SELECT 
    * 
FROM 
    pmse_bpm_event_definition pbed1 
LEFT JOIN 
    pmse_project pp1 
ON 
    pbed1.prj_id = pp1.id 
WHERE 
    pbed1.evn_params = &amp;#39;updated&amp;#39; 
AND 
    pp1.deleted = 0 
AND 
    pbed1.deleted = 0;&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Even if they do not currently have BPM defintions set up in this way, they would need to know to never do that without first disabling the data archiver job for pmse_Inbox. I do not recommend enabling Data Archiver for SugarBPM cleanup.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;There are enhancements logged to improve a few different aspects:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span&gt;90933 - Give the &amp;#39;pmse_Inbox&amp;#39; a more appropriate name in the Data Archiver module list so users know its true scope&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;91044 - Allow Data Archiver to use reports to delete records (this enhancement was referenced to me as a potential solution for properly retaining BPM historical records&amp;nbsp;for the use case cited above)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;92330 - The Data Archiver is limited to 10,000 records per run and has a timeout of 30 minutes when running on the &amp;#39;pmse_Inbox&amp;#39; selection&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span&gt;We recently performed some cleanup for a customer in their pmse_inbox and pmse_bpm_flow tables. These were the queries we had Sugar Support execute to trim down the table size and retain historical references of records previously going through BPM processes since they had a number of BPM definitions with the aforementioned start event criteria:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="sql"&gt;CREATE TABLE 
    pmse_bpm_flow_cleaned LIKE pmse_bpm_flow;

INSERT INTO 
    pmse_bpm_flow_cleaned 
SELECT 
    * 
FROM 
    pmse_bpm_flow 
WHERE 
    pmse_bpm_flow.cas_id NOT IN (
        SELECT 
            cas_id 
        FROM 
            pmse_inbox 
        WHERE 
            cas_status IN (&amp;#39;COMPLETED&amp;#39;, &amp;#39;TERMINATED&amp;#39;) 
        AND 
            date_modified &amp;lt; DATE_SUB(NOW(), INTERVAL 90 DAY) 
    ) 
OR 
    pmse_bpm_flow.cas_index = 1;

RENAME TABLE 
    pmse_bpm_flow TO pmse_bpm_flow_backup, 
    pmse_bpm_flow_cleaned TO pmse_bpm_flow;

CREATE TABLE 
    pmse_inbox_cleaned LIKE pmse_inbox;
    
INSERT INTO 
    pmse_inbox_cleaned 
SELECT 
    * 
FROM 
    pmse_inbox 
WHERE 
    pmse_inbox.cas_status NOT IN (&amp;#39;COMPLETED&amp;#39;, &amp;#39;TERMINATED&amp;#39;) 
OR 
    pmse_inbox.date_modified &amp;gt; DATE_SUB(NOW(), INTERVAL 90 DAY) 
OR 
    pmse_inbox.cas_id NOT IN (
        SELECT cas_id FROM pmse_bpm_flow WHERE cas_index = &amp;#39;1&amp;#39;
    );

RENAME TABLE 
    pmse_inbox TO pmse_inbox_backup, 
    pmse_inbox_cleaned TO pmse_inbox;
    
DROP TABLE IF EXISTS 
    pmse_bpm_flow_backup, 
    pmse_inbox_backup;&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Credit goes to &lt;a href="/members/patrickmcqueen347560"&gt;Patrick McQueen&lt;/a&gt;&amp;nbsp;for those cleanup queries as he had helped someone in SugarClub previously with this same type of request.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Chris&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do we reduce storage cost and improve performance by cleaning BPM tables?</title><link>https://sugarclub.sugarcrm.com/thread/29698?ContentTypeID=1</link><pubDate>Thu, 24 Aug 2023 00:54:12 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:5d26d7b6-4758-4990-80b1-c58342ba2f7c</guid><dc:creator>Enrico Simonetti</dc:creator><description>&lt;p&gt;Thank you &lt;a href="/members/bud-hartley"&gt;Bud Hartley&lt;/a&gt;&amp;nbsp;,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I am not sure if it is the specific system I am looking at, or if you have something special on yours, but the only pmse_ table we see is pmse_Inbox.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;See here:&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:375px;max-width:500px;" alt=" " src="/resized-image/__size/1000x750/__key/communityserver-discussions-components-files/42/data_2D00_archiver.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I was also looking at the actual conditions to delete all related tables that are no longer of interest, as we would not want to inadvertently delete information of in-flight long-running processes...&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do we reduce storage cost and improve performance by cleaning BPM tables?</title><link>https://sugarclub.sugarcrm.com/thread/29697?ContentTypeID=1</link><pubDate>Thu, 24 Aug 2023 00:50:51 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:fe818530-7f62-4850-b701-7019d49a303e</guid><dc:creator>Enrico Simonetti</dc:creator><description>&lt;p&gt;Hey!&lt;/p&gt;
&lt;p&gt;I believe you *could*, in theory, do some of that. Aside from deleting the archived table from Sugar, which you would need Sugar to do.&lt;/p&gt;
&lt;p&gt;It is not for the faint of heart and it requires lots of scripting and a server doing the transformation for the &amp;quot;integration&amp;quot;.&lt;/p&gt;
&lt;p&gt;The archived table is a new table (*_archive), you could then request via API a Sugar backup, download it, extract its content programmatically and, then load the SQL dump into a temporary database, which then pushes the _archive tables to the final offsite archival destination.&lt;/p&gt;
&lt;p&gt;But then you would need someone to delete the archived table for you...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do we reduce storage cost and improve performance by cleaning BPM tables?</title><link>https://sugarclub.sugarcrm.com/thread/29696?ContentTypeID=1</link><pubDate>Thu, 24 Aug 2023 00:34:20 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:95c5d75a-4445-40eb-8e59-a5fe0bde0e9c</guid><dc:creator>Francesca Shiekh</dc:creator><description>&lt;p&gt;That helps if you can hard delete the records.&lt;/p&gt;
&lt;p&gt;The archiver has two options: move to an archive table (does nothing for DB size) or hard delete.&lt;/p&gt;
&lt;p&gt;It would be great if there was an option to archive to an off-site database so that customers had the option to have a data warehouse of older information off of their main Sugar DB.&lt;/p&gt;
&lt;p&gt;Of course this is less of an issue for those of us On-Site since disk space&amp;nbsp;can be more easily managed when you have full control of the database.&lt;/p&gt;
&lt;p&gt;Francesca&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do we reduce storage cost and improve performance by cleaning BPM tables?</title><link>https://sugarclub.sugarcrm.com/thread/29694?ContentTypeID=1</link><pubDate>Wed, 23 Aug 2023 22:39:54 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:6c28a3cc-729b-4005-aa1b-856c283f9fb0</guid><dc:creator>Bud Hartley</dc:creator><description>&lt;p&gt;Hi Enrico,&lt;/p&gt;
&lt;p&gt;We had a serious problem with the growth of the database, and I&amp;#39;ve found the Data Archive function helped to reduce the size.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:375px;max-width:500px;" src="/resized-image/__size/1000x750/__key/communityserver-discussions-components-files/42/pastedimage1692829887367v1.png" alt=" " /&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:375px;max-width:500px;" src="/resized-image/__size/1000x750/__key/communityserver-discussions-components-files/42/pastedimage1692829992104v2.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:375px;max-width:500px;" src="/resized-image/__size/1000x750/__key/communityserver-discussions-components-files/42/pastedimage1692830265591v3.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>