<?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: the performance FGDB API &amp;amp; Arcobjects in File Geodatabase API Questions</title>
    <link>https://community.esri.com/t5/file-geodatabase-api-questions/the-performance-fgdb-api-amp-amp-arcobjects/m-p/389536#M672</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You need to add&amp;nbsp;&amp;nbsp; LoadOnlyMode and SetWriteLock/FreeWriteLock to your code. LoadOnlyMode shuts down index generation and SetWriteLock set a write lock. In ArcObjects a write lock is set when a insert cursor is opened and released when the cursor goes out of scope. Since we do not have a cursor we have to create a write lock on each insert. This slows things down. SetWriteLock opens a write lock until FreeWriteLock is called. When SetWriteLock is called the insert does not create a write lock as it knows that it has already been created. This improves insert (update and modify) performance greatly. I've modified your code.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;fgdbError hr;
&amp;nbsp; wstring&amp;nbsp;&amp;nbsp; errorText;
&amp;nbsp; // Open the geodatabase.
&amp;nbsp; Geodatabase geodatabase;
&amp;nbsp; if ((hr = OpenGeodatabase(L"F:/testData/Editing.gdb", geodatabase)) != S_OK)
&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; wcout &amp;lt;&amp;lt; "An error occurred while opening the geodatabase." &amp;lt;&amp;lt; endl;
&amp;nbsp;&amp;nbsp;&amp;nbsp; ErrorInfo::GetErrorDescription(hr, errorText);
&amp;nbsp;&amp;nbsp;&amp;nbsp; wcout &amp;lt;&amp;lt; errorText &amp;lt;&amp;lt; "(" &amp;lt;&amp;lt; hr &amp;lt;&amp;lt; ")." &amp;lt;&amp;lt; endl;
&amp;nbsp;&amp;nbsp;&amp;nbsp; return ;
&amp;nbsp; }
&amp;nbsp; // Open the Cities table.
&amp;nbsp; Table table;
&amp;nbsp; if ((hr = geodatabase.OpenTable(L"\\Cities", table)) != S_OK)
&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; wcout &amp;lt;&amp;lt; "An error occurred while opening the table." &amp;lt;&amp;lt; endl;
&amp;nbsp;&amp;nbsp;&amp;nbsp; ErrorInfo::GetErrorDescription(hr, errorText);
&amp;nbsp;&amp;nbsp;&amp;nbsp; wcout &amp;lt;&amp;lt; errorText &amp;lt;&amp;lt; "(" &amp;lt;&amp;lt; hr &amp;lt;&amp;lt; ")." &amp;lt;&amp;lt; endl;
&amp;nbsp;&amp;nbsp;&amp;nbsp; return ;
&amp;nbsp; }

&amp;nbsp; // Begin load only mode. This shuts off the update of all indexes.
&amp;nbsp; table.LoadOnlyMode(true);
&amp;nbsp; table.SetWriteLock();

&amp;nbsp; Row cabazonRow;
&amp;nbsp; PointShapeBuffer cabazonGeom;
&amp;nbsp; Point* point;
&amp;nbsp;&amp;nbsp; for (int i = 0; i &amp;lt; 50000; i++)
&amp;nbsp; {
&amp;nbsp;&amp;nbsp; // Create a new feature for Cabazon.
&amp;nbsp;&amp;nbsp; table.CreateRowObject(cabazonRow);

&amp;nbsp;&amp;nbsp; // Set the row's attributes.
&amp;nbsp;&amp;nbsp; cabazonRow.SetString(L"AREANAME", L"Cabazon");
&amp;nbsp;&amp;nbsp; cabazonRow.SetString(L"CLASS", L"town");
&amp;nbsp;&amp;nbsp; cabazonRow.SetInteger(L"POP2000", 2939); // 2007

&amp;nbsp;&amp;nbsp; // Create and assign a point geometry.
&amp;nbsp;&amp;nbsp; hr = cabazonGeom.Setup(shapePoint);
&amp;nbsp;&amp;nbsp; hr = cabazonGeom.GetPoint(point);

&amp;nbsp;&amp;nbsp; point-&amp;gt;x = -116.78443;
&amp;nbsp;&amp;nbsp; point-&amp;gt;y =&amp;nbsp;&amp;nbsp; 33.919902;

&amp;nbsp;&amp;nbsp; cabazonRow.SetGeometry(cabazonGeom);

&amp;nbsp;&amp;nbsp; hr = table.Insert(cabazonRow);

&amp;nbsp; //// Store the row.
&amp;nbsp; //if ((hr = table.Insert(cabazonRow)) != S_OK)
&amp;nbsp; //{
&amp;nbsp; //&amp;nbsp; wcout &amp;lt;&amp;lt; "An error occurred while inserting a row." &amp;lt;&amp;lt; endl;
&amp;nbsp; //&amp;nbsp; ErrorInfo::GetErrorDescription(hr, errorText);
&amp;nbsp; //&amp;nbsp; wcout &amp;lt;&amp;lt; errorText &amp;lt;&amp;lt; "(" &amp;lt;&amp;lt; hr &amp;lt;&amp;lt; ")." &amp;lt;&amp;lt; endl;
&amp;nbsp; //&amp;nbsp; return ;
&amp;nbsp; //}
&amp;nbsp; //else
&amp;nbsp; //{
&amp;nbsp; //&amp;nbsp; wcout &amp;lt;&amp;lt; "Inserted two strings, one integer and a point." &amp;lt;&amp;lt; endl;
&amp;nbsp; //}

&amp;nbsp; }

&amp;nbsp; // End load only mode. This updates of all indexes.
&amp;nbsp; table.LoadOnlyMode(false);
&amp;nbsp; table.FreeWriteLock();&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 17:52:28 GMT</pubDate>
    <dc:creator>LanceShipman</dc:creator>
    <dc:date>2021-12-11T17:52:28Z</dc:date>
    <item>
      <title>the performance FGDB API &amp;amp; Arcobjects</title>
      <link>https://community.esri.com/t5/file-geodatabase-api-questions/the-performance-fgdb-api-amp-amp-arcobjects/m-p/389535#M671</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi, I test insert 50,000 points to a FeatureClass use&amp;nbsp; FGDB API&amp;nbsp; &amp;amp; ArcObjects &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But the result is ArcObjects fast than FGDB API :&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
ArcObjects used time:
Testing with 50,000 points.
Total time taken: 20.5 s

FGDB API used time:
Testing with 50,000 points.
Total time taken: 80.4 s
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My IDE is Visual studio 2010 C++ &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;FGDB API is Final 1.0 version&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ArcObjects 10 version &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is not FGDB API faster than ArcObjects ?&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Below is FGDB API&amp;nbsp; code :&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
fgdbError hr;
&amp;nbsp; wstring&amp;nbsp;&amp;nbsp; errorText;
&amp;nbsp; // Open the geodatabase.
&amp;nbsp; Geodatabase geodatabase;
&amp;nbsp; if ((hr = OpenGeodatabase(L"F:/testData/Editing.gdb", geodatabase)) != S_OK)
&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; wcout &amp;lt;&amp;lt; "An error occurred while opening the geodatabase." &amp;lt;&amp;lt; endl;
&amp;nbsp;&amp;nbsp;&amp;nbsp; ErrorInfo::GetErrorDescription(hr, errorText);
&amp;nbsp;&amp;nbsp;&amp;nbsp; wcout &amp;lt;&amp;lt; errorText &amp;lt;&amp;lt; "(" &amp;lt;&amp;lt; hr &amp;lt;&amp;lt; ")." &amp;lt;&amp;lt; endl;
&amp;nbsp;&amp;nbsp;&amp;nbsp; return ;
&amp;nbsp; }
&amp;nbsp; // Open the Cities table.
&amp;nbsp; Table table;
&amp;nbsp; if ((hr = geodatabase.OpenTable(L"\\Cities", table)) != S_OK)
&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; wcout &amp;lt;&amp;lt; "An error occurred while opening the table." &amp;lt;&amp;lt; endl;
&amp;nbsp;&amp;nbsp;&amp;nbsp; ErrorInfo::GetErrorDescription(hr, errorText);
&amp;nbsp;&amp;nbsp;&amp;nbsp; wcout &amp;lt;&amp;lt; errorText &amp;lt;&amp;lt; "(" &amp;lt;&amp;lt; hr &amp;lt;&amp;lt; ")." &amp;lt;&amp;lt; endl;
&amp;nbsp;&amp;nbsp;&amp;nbsp; return ;
&amp;nbsp; }

&amp;nbsp; Row cabazonRow;
&amp;nbsp; PointShapeBuffer cabazonGeom;
&amp;nbsp; Point* point;
&amp;nbsp;&amp;nbsp; for (int i = 0; i &amp;lt; 50000; i++)
&amp;nbsp; {
&amp;nbsp;&amp;nbsp; // Create a new feature for Cabazon.
&amp;nbsp;&amp;nbsp; table.CreateRowObject(cabazonRow);

&amp;nbsp;&amp;nbsp; // Set the row's attributes.
&amp;nbsp;&amp;nbsp; cabazonRow.SetString(L"AREANAME", L"Cabazon");
&amp;nbsp;&amp;nbsp; cabazonRow.SetString(L"CLASS", L"town");
&amp;nbsp;&amp;nbsp; cabazonRow.SetInteger(L"POP2000", 2939); // 2007

&amp;nbsp;&amp;nbsp; // Create and assign a point geometry.
&amp;nbsp;&amp;nbsp; hr = cabazonGeom.Setup(shapePoint);
&amp;nbsp;&amp;nbsp; hr = cabazonGeom.GetPoint(point);

&amp;nbsp;&amp;nbsp; point-&amp;gt;x = -116.78443;
&amp;nbsp;&amp;nbsp; point-&amp;gt;y =&amp;nbsp;&amp;nbsp; 33.919902;

&amp;nbsp;&amp;nbsp; cabazonRow.SetGeometry(cabazonGeom);

&amp;nbsp;&amp;nbsp; hr = table.Insert(cabazonRow);

&amp;nbsp; //// Store the row.
&amp;nbsp; //if ((hr = table.Insert(cabazonRow)) != S_OK)
&amp;nbsp; //{
&amp;nbsp; //&amp;nbsp; wcout &amp;lt;&amp;lt; "An error occurred while inserting a row." &amp;lt;&amp;lt; endl;
&amp;nbsp; //&amp;nbsp; ErrorInfo::GetErrorDescription(hr, errorText);
&amp;nbsp; //&amp;nbsp; wcout &amp;lt;&amp;lt; errorText &amp;lt;&amp;lt; "(" &amp;lt;&amp;lt; hr &amp;lt;&amp;lt; ")." &amp;lt;&amp;lt; endl;
&amp;nbsp; //&amp;nbsp; return ;
&amp;nbsp; //}
&amp;nbsp; //else
&amp;nbsp; //{
&amp;nbsp; //&amp;nbsp; wcout &amp;lt;&amp;lt; "Inserted two strings, one integer and a point." &amp;lt;&amp;lt; endl;
&amp;nbsp; //}

&amp;nbsp; }
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Aug 2011 05:56:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/file-geodatabase-api-questions/the-performance-fgdb-api-amp-amp-arcobjects/m-p/389535#M671</guid>
      <dc:creator>hexuezhou</dc:creator>
      <dc:date>2011-08-10T05:56:31Z</dc:date>
    </item>
    <item>
      <title>Re: the performance FGDB API &amp; Arcobjects</title>
      <link>https://community.esri.com/t5/file-geodatabase-api-questions/the-performance-fgdb-api-amp-amp-arcobjects/m-p/389536#M672</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You need to add&amp;nbsp;&amp;nbsp; LoadOnlyMode and SetWriteLock/FreeWriteLock to your code. LoadOnlyMode shuts down index generation and SetWriteLock set a write lock. In ArcObjects a write lock is set when a insert cursor is opened and released when the cursor goes out of scope. Since we do not have a cursor we have to create a write lock on each insert. This slows things down. SetWriteLock opens a write lock until FreeWriteLock is called. When SetWriteLock is called the insert does not create a write lock as it knows that it has already been created. This improves insert (update and modify) performance greatly. I've modified your code.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;fgdbError hr;
&amp;nbsp; wstring&amp;nbsp;&amp;nbsp; errorText;
&amp;nbsp; // Open the geodatabase.
&amp;nbsp; Geodatabase geodatabase;
&amp;nbsp; if ((hr = OpenGeodatabase(L"F:/testData/Editing.gdb", geodatabase)) != S_OK)
&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; wcout &amp;lt;&amp;lt; "An error occurred while opening the geodatabase." &amp;lt;&amp;lt; endl;
&amp;nbsp;&amp;nbsp;&amp;nbsp; ErrorInfo::GetErrorDescription(hr, errorText);
&amp;nbsp;&amp;nbsp;&amp;nbsp; wcout &amp;lt;&amp;lt; errorText &amp;lt;&amp;lt; "(" &amp;lt;&amp;lt; hr &amp;lt;&amp;lt; ")." &amp;lt;&amp;lt; endl;
&amp;nbsp;&amp;nbsp;&amp;nbsp; return ;
&amp;nbsp; }
&amp;nbsp; // Open the Cities table.
&amp;nbsp; Table table;
&amp;nbsp; if ((hr = geodatabase.OpenTable(L"\\Cities", table)) != S_OK)
&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; wcout &amp;lt;&amp;lt; "An error occurred while opening the table." &amp;lt;&amp;lt; endl;
&amp;nbsp;&amp;nbsp;&amp;nbsp; ErrorInfo::GetErrorDescription(hr, errorText);
&amp;nbsp;&amp;nbsp;&amp;nbsp; wcout &amp;lt;&amp;lt; errorText &amp;lt;&amp;lt; "(" &amp;lt;&amp;lt; hr &amp;lt;&amp;lt; ")." &amp;lt;&amp;lt; endl;
&amp;nbsp;&amp;nbsp;&amp;nbsp; return ;
&amp;nbsp; }

&amp;nbsp; // Begin load only mode. This shuts off the update of all indexes.
&amp;nbsp; table.LoadOnlyMode(true);
&amp;nbsp; table.SetWriteLock();

&amp;nbsp; Row cabazonRow;
&amp;nbsp; PointShapeBuffer cabazonGeom;
&amp;nbsp; Point* point;
&amp;nbsp;&amp;nbsp; for (int i = 0; i &amp;lt; 50000; i++)
&amp;nbsp; {
&amp;nbsp;&amp;nbsp; // Create a new feature for Cabazon.
&amp;nbsp;&amp;nbsp; table.CreateRowObject(cabazonRow);

&amp;nbsp;&amp;nbsp; // Set the row's attributes.
&amp;nbsp;&amp;nbsp; cabazonRow.SetString(L"AREANAME", L"Cabazon");
&amp;nbsp;&amp;nbsp; cabazonRow.SetString(L"CLASS", L"town");
&amp;nbsp;&amp;nbsp; cabazonRow.SetInteger(L"POP2000", 2939); // 2007

&amp;nbsp;&amp;nbsp; // Create and assign a point geometry.
&amp;nbsp;&amp;nbsp; hr = cabazonGeom.Setup(shapePoint);
&amp;nbsp;&amp;nbsp; hr = cabazonGeom.GetPoint(point);

&amp;nbsp;&amp;nbsp; point-&amp;gt;x = -116.78443;
&amp;nbsp;&amp;nbsp; point-&amp;gt;y =&amp;nbsp;&amp;nbsp; 33.919902;

&amp;nbsp;&amp;nbsp; cabazonRow.SetGeometry(cabazonGeom);

&amp;nbsp;&amp;nbsp; hr = table.Insert(cabazonRow);

&amp;nbsp; //// Store the row.
&amp;nbsp; //if ((hr = table.Insert(cabazonRow)) != S_OK)
&amp;nbsp; //{
&amp;nbsp; //&amp;nbsp; wcout &amp;lt;&amp;lt; "An error occurred while inserting a row." &amp;lt;&amp;lt; endl;
&amp;nbsp; //&amp;nbsp; ErrorInfo::GetErrorDescription(hr, errorText);
&amp;nbsp; //&amp;nbsp; wcout &amp;lt;&amp;lt; errorText &amp;lt;&amp;lt; "(" &amp;lt;&amp;lt; hr &amp;lt;&amp;lt; ")." &amp;lt;&amp;lt; endl;
&amp;nbsp; //&amp;nbsp; return ;
&amp;nbsp; //}
&amp;nbsp; //else
&amp;nbsp; //{
&amp;nbsp; //&amp;nbsp; wcout &amp;lt;&amp;lt; "Inserted two strings, one integer and a point." &amp;lt;&amp;lt; endl;
&amp;nbsp; //}

&amp;nbsp; }

&amp;nbsp; // End load only mode. This updates of all indexes.
&amp;nbsp; table.LoadOnlyMode(false);
&amp;nbsp; table.FreeWriteLock();&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:52:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/file-geodatabase-api-questions/the-performance-fgdb-api-amp-amp-arcobjects/m-p/389536#M672</guid>
      <dc:creator>LanceShipman</dc:creator>
      <dc:date>2021-12-11T17:52:28Z</dc:date>
    </item>
    <item>
      <title>Re: the performance FGDB API &amp; Arcobjects</title>
      <link>https://community.esri.com/t5/file-geodatabase-api-questions/the-performance-fgdb-api-amp-amp-arcobjects/m-p/389537#M673</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi, I used code that you supply to me &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The File Geodatabase API use 18 seconds to create points(50000) , faster 2 seconds than Arcobjects &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks !&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Aug 2011 14:31:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/file-geodatabase-api-questions/the-performance-fgdb-api-amp-amp-arcobjects/m-p/389537#M673</guid>
      <dc:creator>hexuezhou</dc:creator>
      <dc:date>2011-08-24T14:31:00Z</dc:date>
    </item>
    <item>
      <title>Re: the performance FGDB API &amp; Arcobjects</title>
      <link>https://community.esri.com/t5/file-geodatabase-api-questions/the-performance-fgdb-api-amp-amp-arcobjects/m-p/389538#M674</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have similar issues with writing to FGDB.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am using FME to process and load various FCs to an ESRI FGDB.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;One example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have found that if I run a 55-65k record FGDB FC truncate job "cleanly" -- meaning without looking at the FGDB in ArcCatalog or touching the FC at all that morning before running the .FMW, it takes about 3 minutes to run my entire processing job.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Yet, if I simply start my day by looking at the FC in ArcCatalog, or some other user looks at the FC in ArcMap before (or during) the time I kick off my .FMW, it increases the job time from 3 minutes to about 25-35 minutes!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I won't even get into the 36 million record .FMW that took 34 hours to run (it has taken 6-8 hours in the past when truncating SDE FCs).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am wondering if this is an FGDB bug, relates to opportunistic locking on the NAS, or something else entirely.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any help?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Aug 2012 21:15:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/file-geodatabase-api-questions/the-performance-fgdb-api-amp-amp-arcobjects/m-p/389538#M674</guid>
      <dc:creator>JacobMaggard</dc:creator>
      <dc:date>2012-08-03T21:15:17Z</dc:date>
    </item>
  </channel>
</rss>

