<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Optimizing STIntersects queries: Versioned Data in a Database View in Geodatabase Questions</title>
    <link>https://community.esri.com/t5/geodatabase-questions/optimizing-stintersects-queries-versioned-data-in/m-p/779852#M1543</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You speak of load times in ArcMap.&amp;nbsp; Are you just testing this in ArcMap or is the final venue/platform for this ArcMap?&amp;nbsp; If the latter, I have found performance and functional issues using versioned views to access versioned data with ArcGIS products instead of using the regular methods for accessing versioned data.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 01 Jul 2016 16:04:49 GMT</pubDate>
    <dc:creator>JoshuaBixby</dc:creator>
    <dc:date>2016-07-01T16:04:49Z</dc:date>
    <item>
      <title>Optimizing STIntersects queries: Versioned Data in a Database View</title>
      <link>https://community.esri.com/t5/geodatabase-questions/optimizing-stintersects-queries-versioned-data-in/m-p/779851#M1542</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif; font-size: 12pt;"&gt;Hi Everyone, I've got a question that is similar to one that has already been answered here: &lt;A href="https://community.esri.com/thread/123934"&gt;Optimizing STIntersects queries&lt;/A&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif; font-size: 12pt;"&gt;That thread concludes that you take a massive performance hit if you try to use STIntersects directly on a versioned view in SQL Server Mgmt Studio because it can't use the spatial index of the versioned view, so it's best to use temporary tables to circumvent the problem. They also threw out a possible solution of manually applying your query to the A tables, but there wasn't an example.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif; font-size: 12pt;"&gt;My trouble is that I am trying to do the same thing, but use my select statement to create a database view. Here is a simplified example:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas; color: blue;"&gt;CREATE&lt;/SPAN&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas;"&gt; &lt;SPAN style="color: blue;"&gt;VIEW&lt;/SPAN&gt; &lt;SPAN style="color: teal;"&gt;dbo&lt;/SPAN&gt;&lt;SPAN style="color: gray;"&gt;.&lt;/SPAN&gt;&lt;SPAN style="color: teal;"&gt;polygonwithpointtotal&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas; color: blue;"&gt;AS&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas; color: blue;"&gt;SELECT&lt;/SPAN&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas;"&gt; &lt;SPAN style="color: fuchsia;"&gt;MIN&lt;/SPAN&gt;&lt;SPAN style="color: gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: teal;"&gt;poly&lt;/SPAN&gt;&lt;SPAN style="color: gray;"&gt;.&lt;/SPAN&gt;&lt;SPAN style="color: teal;"&gt;OBJECTID&lt;/SPAN&gt;&lt;SPAN style="color: gray;"&gt;),&lt;/SPAN&gt; &lt;SPAN style="color: fuchsia;"&gt;MIN&lt;/SPAN&gt;&lt;SPAN style="color: gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: teal;"&gt;poly&lt;/SPAN&gt;&lt;SPAN style="color: gray;"&gt;.&lt;/SPAN&gt;&lt;SPAN style="color: teal;"&gt;NAME&lt;/SPAN&gt;&lt;SPAN style="color: gray;"&gt;),&lt;/SPAN&gt; &lt;SPAN style="color: fuchsia;"&gt;SUM&lt;/SPAN&gt;&lt;SPAN style="color: gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: teal;"&gt;pts&lt;/SPAN&gt;&lt;SPAN style="color: gray;"&gt;.&lt;/SPAN&gt;&lt;SPAN style="color: teal;"&gt;TOTAL&lt;/SPAN&gt;&lt;SPAN style="color: gray;"&gt;),&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas; color: blue;"&gt;geometry&lt;/SPAN&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas; color: gray;"&gt;::&lt;/SPAN&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas; color: teal;"&gt;UnionAggregate&lt;/SPAN&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas; color: gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas; color: teal;"&gt;poly&lt;/SPAN&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas; color: gray;"&gt;.&lt;/SPAN&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas; color: teal;"&gt;SHAPE&lt;/SPAN&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas; color: gray;"&gt;)&lt;/SPAN&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas;"&gt; &lt;SPAN style="color: blue;"&gt;AS&lt;/SPAN&gt; &lt;SPAN style="color: teal;"&gt;SHAPE&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas; color: blue;"&gt;FROM&lt;/SPAN&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas;"&gt; &lt;SPAN style="color: teal;"&gt;dbo&lt;/SPAN&gt;&lt;SPAN style="color: gray;"&gt;.&lt;/SPAN&gt;&lt;SPAN style="color: teal;"&gt;polygon_evw&lt;/SPAN&gt; &lt;SPAN style="color: blue;"&gt;as&lt;/SPAN&gt; &lt;SPAN style="color: teal;"&gt;poly&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas; color: gray;"&gt;LEFT&lt;/SPAN&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas;"&gt; &lt;SPAN style="color: gray;"&gt;JOIN&lt;/SPAN&gt; &lt;SPAN style="color: gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: blue;"&gt;SELECT&lt;/SPAN&gt; &lt;SPAN style="color: gray;"&gt;*&lt;/SPAN&gt; &lt;SPAN style="color: blue;"&gt;FROM&lt;/SPAN&gt; &lt;SPAN style="color: teal;"&gt;dbo&lt;/SPAN&gt;&lt;SPAN style="color: gray;"&gt;.&lt;/SPAN&gt;&lt;SPAN style="color: teal;"&gt;points_evw&lt;/SPAN&gt; &lt;SPAN style="color: blue;"&gt;WITH&lt;/SPAN&gt;&lt;SPAN style="color: gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: blue;"&gt;INDEX&lt;/SPAN&gt;&lt;SPAN style="color: gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: teal;"&gt;S33_idx&lt;/SPAN&gt;&lt;SPAN style="color: gray;"&gt;))&lt;/SPAN&gt; &lt;SPAN style="color: blue;"&gt;WHERE&lt;/SPAN&gt; &lt;SPAN style="color: teal;"&gt;ptsid&lt;/SPAN&gt; &lt;SPAN style="color: gray;"&gt;=&lt;/SPAN&gt; 1&lt;SPAN style="color: gray;"&gt;)&lt;/SPAN&gt; &lt;SPAN style="color: blue;"&gt;AS&lt;/SPAN&gt; &lt;SPAN style="color: teal;"&gt;pts&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas; color: blue;"&gt;ON&lt;/SPAN&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas;"&gt; &lt;SPAN style="color: teal;"&gt;poly&lt;/SPAN&gt;&lt;SPAN style="color: gray;"&gt;.&lt;/SPAN&gt;&lt;SPAN style="color: teal;"&gt;SHAPE&lt;/SPAN&gt;&lt;SPAN style="color: gray;"&gt;.&lt;/SPAN&gt;&lt;SPAN style="color: teal;"&gt;STIntersects&lt;/SPAN&gt;&lt;SPAN style="color: gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: teal;"&gt;pts&lt;/SPAN&gt;&lt;SPAN style="color: gray;"&gt;.&lt;/SPAN&gt;&lt;SPAN style="color: teal;"&gt;SHAPE&lt;/SPAN&gt;&lt;SPAN style="color: gray;"&gt;)&lt;/SPAN&gt; &lt;SPAN style="color: gray;"&gt;=&lt;/SPAN&gt; 1&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas; color: blue;"&gt;GROUP&lt;/SPAN&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas;"&gt; &lt;SPAN style="color: blue;"&gt;BY&lt;/SPAN&gt; &lt;SPAN style="color: teal;"&gt;poly&lt;/SPAN&gt;&lt;SPAN style="color: gray;"&gt;.&lt;/SPAN&gt;&lt;SPAN style="color: teal;"&gt;OBJECTID&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="color: #505050; font-family: arial, helvetica, sans-serif; font-size: 12pt;"&gt;And the hang-up is with the STIntersects method. If I run it with the default tables (without the _evw at the end) the query takes about 1 second - a perfectly reasonable load time when working with a view in ArcMap. But when I use the versioned view it takes about 30 seconds and the execution plan makes no mention of utilizing a spatial view even though I'm trying to force it in the query.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="color: #505050; font-family: arial, helvetica, sans-serif; font-size: 12pt;"&gt;Any suggestions? &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="color: #505050; font-family: arial, helvetica, sans-serif; font-size: 12pt;"&gt;Using: &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="color: #505050; font-family: arial, helvetica, sans-serif; font-size: 12pt;"&gt;ArcGIS for Desktop 10.4&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="color: #505050; font-family: arial, helvetica, sans-serif; font-size: 12pt;"&gt;ArcGIS for Server 10.4&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="color: #505050; font-family: arial, helvetica, sans-serif; font-size: 12pt;"&gt;Microsoft SQL Server 2012 &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Jul 2016 14:14:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/geodatabase-questions/optimizing-stintersects-queries-versioned-data-in/m-p/779851#M1542</guid>
      <dc:creator>ForrestChevaillier1</dc:creator>
      <dc:date>2016-07-01T14:14:04Z</dc:date>
    </item>
    <item>
      <title>Re: Optimizing STIntersects queries: Versioned Data in a Database View</title>
      <link>https://community.esri.com/t5/geodatabase-questions/optimizing-stintersects-queries-versioned-data-in/m-p/779852#M1543</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You speak of load times in ArcMap.&amp;nbsp; Are you just testing this in ArcMap or is the final venue/platform for this ArcMap?&amp;nbsp; If the latter, I have found performance and functional issues using versioned views to access versioned data with ArcGIS products instead of using the regular methods for accessing versioned data.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Jul 2016 16:04:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/geodatabase-questions/optimizing-stintersects-queries-versioned-data-in/m-p/779852#M1543</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2016-07-01T16:04:49Z</dc:date>
    </item>
    <item>
      <title>Re: Optimizing STIntersects queries: Versioned Data in a Database View</title>
      <link>https://community.esri.com/t5/geodatabase-questions/optimizing-stintersects-queries-versioned-data-in/m-p/779853#M1544</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The final venue is for ArcMap, I want this to be a layer accessible by my users. I am testing the speed by running just the SELECT query in SSMS, then I will go ahead and create the view and test it in ArcMap.&lt;/P&gt;&lt;P&gt;-ArcMap loads quickly when I am using the default tables to create the view and SSMS runs the SELECT query in less than a second.&lt;/P&gt;&lt;P&gt;-ArcMap loads slowly when I am using the versioned view to create the view and SSMS runs the SELECT query in 29 seconds.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What are the regular methods of accessing versioned data? I am new to SQL Server and versioning.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Jul 2016 16:19:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/geodatabase-questions/optimizing-stintersects-queries-versioned-data-in/m-p/779853#M1544</guid>
      <dc:creator>ForrestChevaillier1</dc:creator>
      <dc:date>2016-07-01T16:19:45Z</dc:date>
    </item>
    <item>
      <title>Re: Optimizing STIntersects queries: Versioned Data in a Database View</title>
      <link>https://community.esri.com/t5/geodatabase-questions/optimizing-stintersects-queries-versioned-data-in/m-p/779854#M1545</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/45917"&gt;Chloe Thomas&lt;/A&gt;​ when running the query without "_evw" you wouldn't be looking at the default tables. You would be looking at only a single table, referred to as the "base" table. This table contains only the rows that have been fully reconciled with the DEFAULT version and compressed. Because you are only looking at one table it is much faster than the versioned view, which queries over 5 different tables (Base, Adds, Deletes, States, State_Lineage). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In addition, I would avoid using the versioned_view in any ArcGIS application, because it will only ever point to the DEFAULT version of the data. Instead, it is better to just use a copy of the feature class and specify the version that you want to use. This is because the queries that ArcGIS sends to a versioned feature class are much different than the versioned view, including the execution plan. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Two options I would explore are:&lt;/P&gt;&lt;P&gt;1. Use the query in SSMS to create a stand-alone table with a spatial index; regenerating as needed&lt;/P&gt;&lt;P&gt;2. Perform the analysis of aggregation and spatial analysis in ArcGIS instead of SQL&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Jul 2016 18:12:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/geodatabase-questions/optimizing-stintersects-queries-versioned-data-in/m-p/779854#M1545</guid>
      <dc:creator>ChristianWells</dc:creator>
      <dc:date>2016-07-01T18:12:10Z</dc:date>
    </item>
    <item>
      <title>Re: Optimizing STIntersects queries: Versioned Data in a Database View</title>
      <link>https://community.esri.com/t5/geodatabase-questions/optimizing-stintersects-queries-versioned-data-in/m-p/779855#M1546</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you, very useful stuff. I will try out both options in the next few days and let you know what I end up doing. &lt;/P&gt;&lt;P&gt;For option 1, would this entail setting a trigger that re-creates the table every time there is an edit to either the polygons or the points, or did you have another method in mind?&lt;/P&gt;&lt;P&gt;For option &lt;SPAN style="color: #3d3d3d; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;2, could I accomplish this with a &lt;/SPAN&gt;&lt;SPAN style="color: #3d3d3d; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;Query Layer?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Jul 2016 19:47:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/geodatabase-questions/optimizing-stintersects-queries-versioned-data-in/m-p/779855#M1546</guid>
      <dc:creator>ForrestChevaillier1</dc:creator>
      <dc:date>2016-07-05T19:47:57Z</dc:date>
    </item>
  </channel>
</rss>

