Arcengine data deduplication Several methods and performance comparisons [go]

Source: Internet
Author: User

1. After ifeaturecursor cursor query, traverse delete

2. Update cursor Delete ifeaturecursor.deletefeature ()

3, itable.deletesearchedrows Delete

4, IDataset.Workspace.ExecuteSQL

One, several Delete method code

1. Delete in query results

private void Delete1 (Ifeatureclass pfeatureclass)
{
Iqueryfilter pqueryfilter = new Queryfilterclass ();
Pqueryfilter.whereclause = "objectid<=" + deletenum;
Ifeaturecursor pfeaturecursor = Pfeatureclass.search (Pqueryfilter, false); IFeature pfeature = Pfeaturecursor.nextfeature ();
while (pfeature! = null)
{
Pfeature.delete ();
Pfeature = Pfeaturecursor.nextfeature ();
}
System.Runtime.InteropServices.Marshal.ReleaseComObject (Pqueryfilter);
}

2. Update cursor deletion
private void Delete2 (Ifeatureclass pfeatureclass)
{
Iqueryfilter pqueryfilter = new Queryfilterclass ();
Pqueryfilter.whereclause = "objectid<=" + deletenum;
Ifeaturecursor pfeaturecursor = Pfeatureclass.update (Pqueryfilter, false);
IFeature pfeature = Pfeaturecursor.nextfeature ();
while (pfeature! = null)
{
Pfeaturecursor.deletefeature ();
Pfeature = Pfeaturecursor.nextfeature ();
}
System.Runtime.InteropServices.Marshal.ReleaseComObject (Pqueryfilter);
}

3. Delete with Deletesearchedrows
private void Delete4 (Ifeatureclass pfeatureclass)
{
Iqueryfilter pqueryfilter = new Queryfilterclass ();
Pqueryfilter.whereclause = "objectid<=" + deletenum;
ITable ptable = Pfeatureclass as ITable;
Ptable.deletesearchedrows (Pqueryfilter);
System.Runtime.InteropServices.Marshal.ReleaseComObject (Pqueryfilter);
}

4. ExecuteSQL Delete
private void Delete4 (Ifeatureclass pfeatureclass)
{
Idataset Pdataset = Pfeatureclass as Idataset;
PDataset.Workspace.ExecuteSQL ("Delete from" + Pfeatureclass.aliasname + "where objectid<=" + deletenum);
}

Second, test performance and comparison
1, the same data conditions, delete 2000 records

2. Test code

Ifeaturelayer pfeaturelayer = AxMapControl1.Map.get_Layer (0) as Ifeaturelayer;
Ifeatureclass pfeatureclass = Pfeaturelayer.featureclass;
System.Diagnostics.Stopwatch Mywatch = new System.Diagnostics.Stopwatch ();
Mywatch.start ();
Delete1 (Pfeatureclass)
Delete2 (Pfeatureclass);
Delete3 (Pfeatureclass);
Delete4 (Pfeatureclass);
Delete5 (Pfeatureclass);
Mywatch.stop ();
MessageBox.Show ("Delete time:" + MyWatch.ElapsedMilliseconds.ToString () + "millisecond");
3. Test situation
Test method
First time (unit ms)
First time (unit ms)
1
5214ms
5735ms

2
299ms
290Ms

3
59ms
28ms

4
26ms
26ms

Iii. Conclusion

1, using ExecuteSQL delete the fastest, the database is the most efficient.

2, Deletesearchedrows and ExecuteSQL belong to bulk Delete, better performance.

3, the query results deleted, the slowest, if you use this method, set up you immediately modify your program, because you are wasting time.

4.

The number of small data records is less than 500,000, use deletesearchedrows or executesql, otherwise use the Update cursor Delete (method 2), plus the progress bar, so that the interface is friendly.

Arcengine data deduplication Several methods and performance comparisons [go]

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.