<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.appian.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>Memory Threshold Issue</title><link>https://community.appian.com/discussions/f/reports/21301/memory-threshold-issue</link><description>Hi, 
 
 We are facing the below error while trying to execute the expression rule to fetch data from data base table: 
 
 An error occurred while evaluating expression: listofIDtodelete:rule!abc(cons!xyz) (Expression evaluation error in rule &amp;#39;abc&amp;#39; at</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Memory Threshold Issue</title><link>https://community.appian.com/thread/83105?ContentTypeID=1</link><pubDate>Tue, 29 Jun 2021 13:35:29 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:42c5ee16-805f-4bdf-b6f3-554016c89dfe</guid><dc:creator>Peter Lewis</dc:creator><description>&lt;p&gt;Agreed with the solutions suggested for truncating a table, but we still haven&amp;#39;t gotten to the fundamental problem: why do you need to delete all of this data? Is this a temporary table that you&amp;#39;re using for ETL purposes? How is the data getting populated in this table?&lt;/p&gt;
&lt;p&gt;I&amp;#39;m concerned that this is an &lt;a href="https://en.wikipedia.org/wiki/XY_problem"&gt;XY problem&lt;/a&gt; where we&amp;#39;re trying to solve the wrong problem.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Memory Threshold Issue</title><link>https://community.appian.com/thread/83103?ContentTypeID=1</link><pubDate>Tue, 29 Jun 2021 13:17:05 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:eade6034-0e10-4745-b649-304cebf6ff55</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;Overall I agree with you guys about how best to truncate a table (assuming they want to make their PK IDs to start back at zero, unless I&amp;#39;m mistaken about what TRUNCATE does).&amp;nbsp; But this inefficient querying is something I see across all sorts of use cases so I always try to point it out anyway ;-)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Memory Threshold Issue</title><link>https://community.appian.com/thread/83101?ContentTypeID=1</link><pubDate>Tue, 29 Jun 2021 13:07:28 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:f2311ffe-4052-4330-9276-136179557c30</guid><dc:creator>davel001150</dc:creator><description>&lt;p&gt;I agree with Stefan.&amp;nbsp; You&amp;#39;re making this about two hundred thousand times harder than it needs to be.&amp;nbsp; You&amp;#39;re gathering 100,000 ids, storing 100,000 IDs in a PV, then doing 100 subprocesses that each handle a Delete from Datastore node that is MNI 1000 times.&amp;nbsp; Or maybe trying a forEach with a delete from datastore rule that can be cloned up to a million times.&amp;nbsp; For what?&amp;nbsp; Since you&amp;#39;re not filtering, your ultimate result will be an empty table.&lt;/p&gt;
&lt;p&gt;Just use the TRUNCATE command.&amp;nbsp; One step.&amp;nbsp; No Appian, no PV with mountain of data eating your RAM, no looping.&amp;nbsp; Just a few seconds and empty table.&amp;nbsp; Just get a DBA to TRUNCATE the table if you want it to have 0 rows.&amp;nbsp; Or &amp;quot;Execute Stored Procedure&amp;quot; and the stored procedure in question has only 1 line of code: TRUNCATE TABLE &amp;lt;name&amp;gt;;&lt;/p&gt;
&lt;p&gt;Good point Mike, but we&amp;#39;re in the realm of optimizing code before removing it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Memory Threshold Issue</title><link>https://community.appian.com/thread/83100?ContentTypeID=1</link><pubDate>Tue, 29 Jun 2021 13:04:24 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:a7a30202-cc28-4493-942f-040cf67e8488</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;In addition to what Stefan said - in your first query, there is no need to pull back all rows of a query (&amp;quot;batchSize: -1&amp;quot;) when you&amp;#39;re just checking that the totalCount is zero.&amp;nbsp; Instead set your batchsize to Zero, which makes the query pull back metadata (including TotalCount) but not pull back any rows of data.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Memory Threshold Issue</title><link>https://community.appian.com/thread/83098?ContentTypeID=1</link><pubDate>Tue, 29 Jun 2021 09:31:15 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:d9e1e7ed-8e82-46c5-9644-dd59a96a0c06</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;&lt;a href="https://docs.appian.com/suite/help/21.2/Local_Variables.html"&gt;https://docs.appian.com/suite/help/21.2/Local_Variables.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://academy.appian.com/#/curricula/4ec18f7b-604e-4473-b476-87279969c946"&gt;academy.appian.com/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;But, again, this will not solve your root problem. Trying to delete 100ks of rows in DB with that method is no good idea.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Memory Threshold Issue</title><link>https://community.appian.com/thread/83095?ContentTypeID=1</link><pubDate>Tue, 29 Jun 2021 08:51:51 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:9da84b8d-5e8d-49eb-83e4-9459cb984dc6</guid><dc:creator>ayushimittal</dc:creator><description>&lt;p&gt;Hi Stefan,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;How can I store the single column of data store entity in local variable?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Memory Threshold Issue</title><link>https://community.appian.com/thread/83093?ContentTypeID=1</link><pubDate>Tue, 29 Jun 2021 08:12:18 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:c16630a6-2a82-4a4e-8082-12ba150185cf</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;First, I strongly suggest to not do that query two times in the if() statement. Create a local variable and store the data there.&lt;/p&gt;
&lt;p&gt;Next. This seems like you want to delete all rows in that table. MariaDB has a special comment for this. It is called &amp;quot;truncate&amp;quot;. I suggest to write a small stored procedure and use that.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Memory Threshold Issue</title><link>https://community.appian.com/thread/83092?ContentTypeID=1</link><pubDate>Tue, 29 Jun 2021 08:08:11 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:c87777be-c502-4f90-bef9-e619c7582f04</guid><dc:creator>ayushimittal</dc:creator><description>&lt;p&gt;Hi Stewart,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;We are fetching a single column (ID) data from one database table so will it be helpful to create a view in this case?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Memory Threshold Issue</title><link>https://community.appian.com/thread/83091?ContentTypeID=1</link><pubDate>Tue, 29 Jun 2021 08:06:46 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:f54f54cf-7615-4568-8634-ed5256cce1ff</guid><dc:creator>ayushimittal</dc:creator><description>&lt;p&gt;Hi Stefen,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Please find the expression rule code, we are using to fetch the data from database table:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!entityDataIdentifiers(
  entity: ri!Entity,
  identifiers: {
    if(
      a!queryEntity(
        entity: ri!Entity,
        query: a!query(
          selection: a!querySelection(
            columns: {
              a!queryColumn(
                field: &amp;quot;id&amp;quot;
              )
            }
          ),
          pagingInfo: a!pagingInfo(
            startIndex: 1,
            batchSize: - 1
          )
        ),
        fetchTotalCount: true
      ).Totalcount = 0,
      &amp;quot;&amp;quot;,
      a!queryEntity(
        entity: ri!Entity,
        query: a!query(
          selection: a!querySelection(
            columns: {
              a!queryColumn(
                field: &amp;quot;id&amp;quot;
              )
            }
          ),
          pagingInfo: a!pagingInfo(
            startIndex: 1,
            batchSize: - 1
          )
        ),
        fetchTotalCount: false
      ).data.id
    )
  }
)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Please let me know how can I optimize it as it is fetching all the IDs need to be deleted.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Memory Threshold Issue</title><link>https://community.appian.com/thread/83077?ContentTypeID=1</link><pubDate>Tue, 29 Jun 2021 06:12:53 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:beb098ad-9e88-441b-843d-d804c28ae5cf</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;Is this part of a larger DB cleanup process? Will it run periodically? Why is there so much to clean up? Could it be prevented?&lt;/p&gt;
&lt;p&gt;Is the query to fetch the IDs a simple one? Like &amp;quot;select id from table where tobedeleted=1&amp;quot;? If yes, did you consider to use the Query Database Node and a statement like &amp;quot;delete from table where tobedeleted=1&amp;quot;. There is some drawbacks going that way, but it might be worth it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Memory Threshold Issue</title><link>https://community.appian.com/thread/83074?ContentTypeID=1</link><pubDate>Tue, 29 Jun 2021 05:56:14 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:dd8f7686-cdbe-4475-9b63-398aab52d080</guid><dc:creator>ayushimittal</dc:creator><description>&lt;p&gt;Hi Peter, &lt;/p&gt;
&lt;p&gt;Using expression rule, We are fetching all the IDs from the database table and passing it to script task in the process model as the &amp;#39;IDs to be deleted&amp;#39;. &lt;/p&gt;
&lt;p&gt;While we are executing this process model, it is failing on this script task and throwing the above error. &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Memory Threshold Issue</title><link>https://community.appian.com/thread/83060?ContentTypeID=1</link><pubDate>Mon, 28 Jun 2021 17:05:07 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:630cfdef-f753-49a4-b254-56561883e063</guid><dc:creator>Peter Lewis</dc:creator><description>&lt;p&gt;I think we need to take a step back - what is your use case? There might be a completely different query you could run depending on what you&amp;#39;re trying to do. How are you using this data? What is the goal?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Memory Threshold Issue</title><link>https://community.appian.com/thread/83059?ContentTypeID=1</link><pubDate>Mon, 28 Jun 2021 16:59:27 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:ef211788-0b35-4b29-aca8-b80934b1f23c</guid><dc:creator>Stewart Burchell</dc:creator><description>&lt;p&gt;Could you do the &amp;quot;heavy lifting&amp;quot; in the database itself? That is, use the database aggregation functions to generate a view (virtual or materialised) and then point Appian at the result table in order to present the data.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Memory Threshold Issue</title><link>https://community.appian.com/thread/83056?ContentTypeID=1</link><pubDate>Mon, 28 Jun 2021 16:33:31 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:dbe2a380-bcd0-4d31-b5cd-bacd14f9e184</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;Then I defer to &amp;#39;s original suggestion of employing Batching somehow within your process.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Memory Threshold Issue</title><link>https://community.appian.com/thread/83055?ContentTypeID=1</link><pubDate>Mon, 28 Jun 2021 16:29:10 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:610790ac-be42-49a5-935a-bf66f124430d</guid><dc:creator>ayushimittal</dc:creator><description>&lt;p&gt;We are fetching only a single column (ID) of the database table but there are over 2 Lakh rows. &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Memory Threshold Issue</title><link>https://community.appian.com/thread/83048?ContentTypeID=1</link><pubDate>Mon, 28 Jun 2021 15:01:26 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:7eda4b6c-c96f-42e6-bead-e0c47c19c8df</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;Considering that you seem to be fetching &amp;quot;&lt;span&gt;listofIDtodelete&lt;/span&gt;&amp;quot; - how many columns are you returning in your query?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Memory Threshold Issue</title><link>https://community.appian.com/thread/83034?ContentTypeID=1</link><pubDate>Mon, 28 Jun 2021 11:51:58 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:4f444d53-a480-4e1d-93be-2e2856394cbc</guid><dc:creator>davel001150</dc:creator><description>&lt;p&gt;One possibility might be Execute Stored Procedure.&amp;nbsp; That can also be called upon to run a database FUNCTION, which can return simply the results of your aggregation.&amp;nbsp; I assume you just want things like COUNT, AVE, MIN, MAX.&amp;nbsp; You can have the DB run all the aggregation calculations and have it return only the few integers you need, if what you need is a few integers.&amp;nbsp; That way, you don&amp;#39;t have to bring the whole dataset to bear for Appian to perform aggregation, but let the DB do it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Memory Threshold Issue</title><link>https://community.appian.com/thread/83033?ContentTypeID=1</link><pubDate>Mon, 28 Jun 2021 11:26:07 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:1df379f6-c58b-4442-a38c-346afabbca85</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;Then you need to optimize your query. Do your really need all data returned? Is this about reporting into Excel or charts?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Memory Threshold Issue</title><link>https://community.appian.com/thread/83032?ContentTypeID=1</link><pubDate>Mon, 28 Jun 2021 11:23:15 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:d50b1838-f5a2-40db-aeae-ef53e6e9288a</guid><dc:creator>ayushimittal</dc:creator><description>&lt;p&gt;Thanks Stefan for your prompt response.&lt;/p&gt;
&lt;p&gt;But we are using this data for reporting purpose. The aggregation functions are applied on the whole data so how can we apply batching logic in it.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Memory Threshold Issue</title><link>https://community.appian.com/thread/83031?ContentTypeID=1</link><pubDate>Mon, 28 Jun 2021 11:15:59 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:b701733e-6707-410c-9943-0fb0f36d760a</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;The only sustainable solution is to refactor your design. Think of batching, looping etc.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>