Jump to content
Mark Williams

FireDac PostgreSQL and TBatchMove

Recommended Posts

Has anyone been able to get the BatchMove component to work correctly with PostgreSQL in AppendUpdate mode where there is an auto inc key field?

 

My BatchMove component creation code is below.

 

In addition, either the FDConnectionPG ExtendedMetaData param is set to true or the FDQueryPG updateOptions.AutoIncFields is set. Either way produces the same result, although I understand there is an efficiency hit with use of ExtendedMetaData.

 

The problem is that whilst new rows get added to the table and my auto inc key field value gets set, it is running backwards ie -1, -2, -3 etc.  Am I missing something or is this a bug?

 var
    FBatchMove: TFDBatchMove;
    FReader: TFDBatchMoveDataSetReader;
    FWriter: TFDBatchMoveSQLWriter;
    F:TField;
begin
   FBatchMove := TFDBatchMove.Create(nil);
   FReader := TFDBatchMoveDataSetReader.Create(FBatchMove);
   FWriter := TFDBatchMoveSQLWriter.Create(FBatchMove);
   try
     FReader.DataSet:=FDQueryPG;
     FWriter.Connection:=FDConnectionPG;
     FWriter.TableName:='dummy';
     FBatchMove.CommitCount:=1000;
     FBatchMove.Mode := dmAppendUpdate;
     FBatchMove.options:=FBatchmove.Options+[poIdentityInsert];
     FBatchMove.Execute;
  finally
        FWriter.Free;
        FReader.Free;
        FBatchMove.Free;
  end;


 

 

 

Edited by Mark Williams
Update

Share this post


Link to post

ExtendedMetaData slows things WAAAAAAAAAAYYYYYYYYYYYYY down! Don't enable it unless you absolutely need it! (I'm using PgDAC components, and we traced this into an auto-generated second query that is issued to the server after every query to get metadata for the previous query, and it runs slower than molasses in winter! We couldn't figure out why, but we just set the component to generate V2 queries rather than V3 queries to always suppress the metadata inquiry. Otherwise, you have to do it on each query you issue. But again, that's PgDAC.)

 

Share this post


Link to post
6 hours ago, Mark Williams said:

That's good to know. Thanks. Have you any experience of Batchmove and reverse inrements?

no, sorry.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×