<?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>View Optimization</title><link>https://community.appian.com/discussions/f/general/13223/view-optimization</link><description>Hi, 
 I have requirement to optimize a view. The structure of view is available as below with multiple select commands based on code. 
 SELECT `S`.`ID` AS `ID`, (select `TEST_MASTER_DATA`.`LABEL` from `TEST_MASTER_DATA` where ((`TEST_MASTER_DATA`.`CODE</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: View Optimization</title><link>https://community.appian.com/thread/60961?ContentTypeID=1</link><pubDate>Tue, 02 Oct 2018 00:09:31 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:842673ac-fb3b-41ea-98d1-82ce24f2efc4</guid><dc:creator>nicholash893817</dc:creator><description>You will need to add indexes as others have suggested on the Join Columns.  In general, if queries or views are being performed on a table where filtering or joining needs to occur you should take the time to research the proper syntax and which indexes are appropriate to use  (ie fulltext vs index)&lt;br /&gt;
&lt;br /&gt;
If you are using MySQL, queries don&amp;#39;t always automatically use the best indexes available, but I have had success in utilizing the &amp;#39;USE INDEX&amp;#39; syntax&lt;br /&gt;
&lt;br /&gt;
If you are going to be filtering on the view (ie. select * from view where condition=true) I would suggest instead to use a stored procedure to construct a sql query for this data.  When querying against a view the indexes on the underlying tables aren&amp;#39;t used and you will run into performance issues.&lt;br /&gt;
&lt;br /&gt;
You should also utilize the EXPLAIN SELECT on your query to find out if any full table scans are being performed and try to limit those&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: View Optimization</title><link>https://community.appian.com/thread/60960?ContentTypeID=1</link><pubDate>Mon, 01 Oct 2018 22:58:36 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:d3dc0a36-a051-402a-9448-cb5888849894</guid><dc:creator>sahithip120</dc:creator><description>Try applying indexes on the join columns for better view performance&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: View Optimization</title><link>https://community.appian.com/thread/60951?ContentTypeID=1</link><pubDate>Mon, 01 Oct 2018 20:39:46 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:9e86ab28-ecc3-417e-b0e7-03945a3c0d1e</guid><dc:creator>charlesm492</dc:creator><description>Agreed.  It doesn&amp;#39;t seem to serve any purpose as a left join, but as an inner join it could be used to filter the data and would possibly perform better because it would fetch a potentially smaller volume of data with less duplicates.&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: View Optimization</title><link>https://community.appian.com/thread/60949?ContentTypeID=1</link><pubDate>Mon, 01 Oct 2018 20:33:00 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:e704846c-be3a-41e8-b559-110944ac6802</guid><dc:creator>Larry Nguyen</dc:creator><description>I noticed you aren&amp;#39;t SELECTing any columns from Test_FollowUp or the Alias &amp;#39;F&amp;#39;.  Do you need to LEFT JOIN on that table?  Or was that meant to be an INNER JOIN?&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: View Optimization</title><link>https://community.appian.com/thread/59724?ContentTypeID=1</link><pubDate>Wed, 29 Aug 2018 12:40:22 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:1e2e3127-95e6-4d07-a8ab-b40d4b17568a</guid><dc:creator>Abhay Giri</dc:creator><description>&lt;p&gt;indexing, where ? in view?&lt;/p&gt;
&lt;p&gt;if you can&amp;#39;t implement the above way then we can optimize the view itself. May be the chances that we can rearrange the view for better performance.&lt;/p&gt;
&lt;p&gt;you can also refer the below link : it has some very good suggestion to optimize the query.Cross check with your query may be you will find some way to improve your query.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://www.safaribooksonline.com/library/view/high-performance-mysql/9780596101718/ch04.html"&gt;https://www.safaribooksonline.com/library/view/high-performance-mysql/9780596101718/ch04.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://dev.mysql.com/doc/refman/8.0/en/view-restrictions.html"&gt;https://dev.mysql.com/doc/refman/8.0/en/view-restrictions.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;If you face the problem then we need query to examine.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;
&lt;p&gt;Abhay Giri&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: View Optimization</title><link>https://community.appian.com/thread/59723?ContentTypeID=1</link><pubDate>Wed, 29 Aug 2018 12:24:16 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:c72c8596-decc-4dc5-9653-5ffea8e40f20</guid><dc:creator>krishnaprasadd0001</dc:creator><description>Hi Abhay ,&lt;br /&gt;
&lt;br /&gt;
I completely agree that creating a table will increase the performance in fetching the data but right now the code was in Prod and they dont want any major changes to happen. Can you please let me know indexing will increase performance on fetching data and if so can you please let me know the way to do it.&lt;br /&gt;
&lt;br /&gt;
Thanks&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: View Optimization</title><link>https://community.appian.com/thread/59716?ContentTypeID=1</link><pubDate>Wed, 29 Aug 2018 09:24:47 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:84ebc72a-418d-484e-b3dc-15eb12b8b194</guid><dc:creator>Abhay Giri</dc:creator><description>right, we use boolean variable to mark the record that this records has been fetched so in next time will retrieve next record not this one. Suppose your temp table will get 1000 records from view so in my logic, will fetch this 1000 records in 5 time 1000/5=200 each time. When first time data will fetch then first 200 record will come and this boolean variable marked as true  so in second time will fetch records from 201-400 as so on.&lt;br /&gt;
&lt;br /&gt;
Abhay&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: View Optimization</title><link>https://community.appian.com/thread/59715?ContentTypeID=1</link><pubDate>Wed, 29 Aug 2018 09:21:16 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:0469fc97-791c-44f0-a6d5-9c2659683874</guid><dc:creator>krishnaprasadd0001</dc:creator><description>Hi Abhi,&lt;br /&gt;
&lt;br /&gt;
Do you want me to populate the temp table also whenever the sales table is getting populated similar to the data how view is getting formed right?  what is the use of boolean column?&lt;br /&gt;
&lt;br /&gt;
Thanks&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: View Optimization</title><link>https://community.appian.com/thread/59710?ContentTypeID=1</link><pubDate>Wed, 29 Aug 2018 08:59:19 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:49d4f5fb-a1f1-44fb-a0f9-d7a8ee455da3</guid><dc:creator>Abhay Giri</dc:creator><description>Hi Krishna,&lt;br /&gt;
&lt;br /&gt;
You can try the way as well, if it suits in your requirement:&lt;br /&gt;
&lt;br /&gt;
1-&amp;gt; create a table with the same columns as in your view has.&lt;br /&gt;
2-&amp;gt; instead of fetching the data from view into Appian, fetch the data in the table with one extra column, i.e basically it will be a bool column.&lt;br /&gt;
3-&amp;gt;Now fetch the data from this table instead of view but we are not going to fetch data at once. Will fetch the data in batches .Just divided the whole data into small batches and then fetch. Once all data will be fetched then generate the excel file.&lt;br /&gt;
&lt;br /&gt;
It requires little bit changes but it surly help you.&lt;br /&gt;
&lt;br /&gt;
Regards&lt;br /&gt;
Abhay&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: View Optimization</title><link>https://community.appian.com/thread/59706?ContentTypeID=1</link><pubDate>Wed, 29 Aug 2018 08:03:19 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:44149c5f-ad43-4d44-9720-8e3ab0a581ba</guid><dc:creator>krishnaprasadd0001</dc:creator><description>Hi Hema,&lt;br /&gt;
&lt;br /&gt;
Similar to that we have 15 select commands in View referring to master data based upon code values in Test_sales.  Since we are having multiple commands we are writing select commands there only instead of joining the master table.&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: View Optimization</title><link>https://community.appian.com/thread/59705?ContentTypeID=1</link><pubDate>Wed, 29 Aug 2018 08:00:00 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:bc786aec-532e-4775-b886-295413baff05</guid><dc:creator>krishnaprasadd0001</dc:creator><description>Hi shanmukh,&lt;br /&gt;
&lt;br /&gt;
Since the application is already implemented we just want to make changes to optimize the code without much changes. Since we have too much data in DB even query entity is not able to fetch that data. we are using this view to export the data to excel using Export Sql to Excel/CSV smart service where it is taking too much time. &lt;br /&gt;
Is there any way to optimize the view query if it is possible?&lt;br /&gt;
&lt;br /&gt;
Thanks&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: View Optimization</title><link>https://community.appian.com/thread/59704?ContentTypeID=1</link><pubDate>Wed, 29 Aug 2018 07:49:45 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:63ffd823-5978-4765-9a1c-1081e124bd4d</guid><dc:creator>Shanmukha</dc:creator><description>Hi Krishna,&lt;br /&gt;
&lt;br /&gt;
It all depends on the actual requirement what needs to be included and what can be excluded from the tables that your are joining. We have also had so many tables joined through the view some times we get pink error while retrieving the data.&lt;br /&gt;
&lt;br /&gt;
What is the delay that you are currently experiencing on UI? Of course the view is having double select one is from Appian and other is actual select of the view.&lt;br /&gt;
&lt;br /&gt;
If you are okay I would recommend to user the SP which can return wither xml or json if it oracle 12g Enterprise edition. This would be the last option.&lt;br /&gt;
&lt;br /&gt;
I would also suggest that, DBA can only help in this case.&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: View Optimization</title><link>https://community.appian.com/thread/59703?ContentTypeID=1</link><pubDate>Wed, 29 Aug 2018 07:43:00 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:78ec72b5-b5b2-4e30-becf-e7b690a74f11</guid><dc:creator>Hema</dc:creator><description>Hi Krishnaprasad,&lt;br /&gt;
&lt;br /&gt;
Can you try the below SQL and see if it works,&lt;br /&gt;
&lt;br /&gt;
SELECT &lt;br /&gt;
&amp;#96;S&amp;#96;.&amp;#96;ID&amp;#96; AS &amp;#96;ID&amp;#96;,&lt;br /&gt;
&amp;#96;M&amp;#96;.&amp;#96;LABEL&amp;#96; AS &amp;#96;STATUS_CODE&amp;#96;,&lt;br /&gt;
&amp;#96;S&amp;#96;.&amp;#96;INFO&amp;#96; AS &amp;#96;INFO&amp;#96;&lt;br /&gt;
FROM &amp;#96;Test_Sales&amp;#96; &amp;#96;S&amp;#96;&lt;br /&gt;
LEFT JOIN &amp;#96;Test_FollowUp&amp;#96; &amp;#96;F&amp;#96; ON &amp;#96;S&amp;#96;.&amp;#96;ID&amp;#96;= &amp;#96;F&amp;#96;.&amp;#96;ID&amp;#96; &lt;br /&gt;
LEFT JOIN &amp;#96;TEST_MASTER_DATA&amp;#96; &amp;#96;M&amp;#96; ON &amp;#96;M&amp;#96;.&amp;#96;CODE&amp;#96; = &amp;#96;S&amp;#96;.&amp;#96;CODE&amp;#96; AND &amp;#96;M&amp;#96;.&amp;#96;FIELD&amp;#96; = 5;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Thanks,&lt;br /&gt;
Hema&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>