Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8591907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:37:44+00:00 2026-06-11T23:37:44+00:00

I need to improve the performance of data loading. The current algorythm makes a

  • 0

I need to improve the performance of data loading. The current algorythm makes a full select from a table:

select Field1, Field2,...,FieldN from Table1 order by FieldM

The new data is read from a text file (say, textfile line per datatable row).
The table has a primary key, containing two fields. For each line of a textfile it locates the necessary row by these two fields (i.e. the primary key).

query.Locate('Field1;Field2',VarArrayOf([Value1,Value2]),[]);

If Locate returns True, it edits the row, otherwise it appends a new one.

So, as far as the table consists of about 200000 rows, each Locate operation takes certain amount of time…so it manages to update about 5-6 rows per second.

What things should I consider to improve it?

Probably replace locating through this great select with separate queries?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T23:37:45+00:00Added an answer on June 11, 2026 at 11:37 pm

    DON’T use Locate(). If you use locate() then Delphi searches row on the client side just scanning row set from your query it takes a LOT of time.

    If you have access to MSSQL to create stored procedures then create following procedure and just run it for each line from your TEXT file without any conditions (Use TAdoStoredProc.ExecProc in Delphi). So in this case your don’t need first select and Locate procedure. It updates record if Filed1 and Field2 are found and insert if don’t.

    CREATE PROCEDURE dbo.update_table1 
    @Field1 int, --key1
    @Field2 int, --key2
    @Field3 int, -- data fileds
    @Field4 int
    
    AS
    
    SET NOCOUNT ON
    update table1 set Field3=@Field3,Field4=@Field4 
            where Field1=@Field1 and Field2=@Field2;
    IF(@@Rowcount=0)
    BEGIN
         insert into table1(Field1,Field2,Field3,Field4) 
                    values (@Field1,@Field2,@Field3,@Field4);
    END
    GO
    

    Here is Delphi code to invoke this stored procedure with ADO:

    ......
    var 
         ADOStoredP: TADOStoredProc;
    
      ......
    begin
    
    ........
        ADOStoredP:=TADOStoredProc.Create(nil);
       try
          ADOStoredP.Connection:=DataMod.SQL_ADOConnection; //Your ADO Connection instance here
          ADOStoredP.ProcedureName:='Update_table1';
          ADOStoredP.Parameters.CreateParameter('@Field1', ftInteger, pdInput, 0, 0);
          ADOStoredP.Parameters.CreateParameter('@Field2', ftInteger, pdInput, 0, 0);
          ADOStoredP.Parameters.CreateParameter('@Field3', ftInteger, pdInput, 0, 0);
          ADOStoredP.Parameters.CreateParameter('@Field4', ftInteger, pdInput, 0, 0);
    
          While () -- Your text file loop here
          begin
    
          ADOStoredP.Parameters.ParamByName('@Field1').Value:=Field1 value from text file here;
          ADOStoredP.Parameters.ParamByName('@Field2').Value:=Field2 value from text file here;
          ADOStoredP.Parameters.ParamByName('@Field3').Value:=Field3 value from text file here;
          ADOStoredP.Parameters.ParamByName('@Field4').Value:=Field4 value from text file here;
    
          ADOStoredP.ExecProc;
    
          end
    
        finally
          if Assigned(ADOStoredP) then
            begin
             ADOStoredP.Free;
            end;
        end;
    
    ........
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I didn't use NGen before but now I need to improve startup performance of
I need to improve memory performance on my application and I could see that
I need to improve the response time for a Grails application, so I need
I need to improve on a regular expression I'm using. Currently, here it is:
I have recently started to feel that I need to greatly improve my C++
I need to implement threading to improve load time in a compact framework app.
Please help me to improve the following script: http://jsfiddle.net/n9BkM/8/ I need the following fucntionality:
I want to encrypt/decrypt lots of small (2-10kB) pieces of data. The performance is
My application has to deal with large amounts of data, usual select size is
I've just started a small library which will need to screen scrape from various

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.