Search Method |
Disadvantages |
Advantages |
Locate |
All data will be downloaded from the data source. If the data table contains a large amount of data, the execution efficiency will be very slow, and it will easily cause the client to become a machine. |
The query data execution efficiency remains stable, regardless of whether the data to be searched already exists in the result data set, and there are no other side effects |
Use clonecursor |
If the data to be searched is not in the result data set, all the data in the data table will be downloaded, and the performance is slower than using the locate method. |
If the data to be searched already exists in the result data set, it can avoid downloading all the data and quickly locate the data to be searched. |
Use clonecursor to add SQL statements and appenddata |
Possible side effects of duplicate data |
Provides the fastest query efficiency, regardless of whether the data is in the result data set or the back-end data source. At the same time, the downloaded data volume is the least, and the network load is the least. |
Use copy data |
The program must copy some additional data. |
It provides better search efficiency than direct use of locate and other methods, without the disadvantages of the clonecursor method or the side effects of clonecursor and SQL statements |
Additional description: The Method for Improving the query speed in SQL.
To ensure that duplicate values are eliminated, subqueries must process nested queries for each result of an external query. In this case, you can consider using join queries instead.
If you want to use a subquery, use exists instead of in and not exists instead of not in. Because the subquery introduced by exists only tests whether there are rows that meet the specified conditions in the subquery, the efficiency is high. In either case, not in is the most inefficient. Because it executes a full table traversal for the table in the subquery.
Create a proper index to avoid scanning excess data and table scanning!
Millions of data records can be queried in dozens of milliseconds.