Re: Performance enhancement

From: jpatton (jppatton_at_vt.edu)
Date: 05/12/04


Date: Wed, 12 May 2004 08:46:03 -0400

Ok I am trying to follow you here so I hope I make sense... I am new at this
and the two senior developers I go to with questions are out this week so
you all have been a great help!

I am actually doing a select as you said (by relating the two different data
sources)... here is the actual code:

      adoAwrdsQty.SQL.Add( 'SELECT EL_Id, Quantity FROM
EL_Item_Characteristics' );
      adoAwrdsQty.SQL.Add( ' WHERE Serial_No =
'+#39+adoGetEndItem.FieldByName( 'Serial_No' ).AsString+#39 );
      adoAwrdsQty.SQL.Add( ' AND NIIN = '+#39+adoGetEndItem.FieldByName(
'EI_NIIN' ).AsString+#39 );
      adoAwrdsQty.SQL.Add( ' AND EL_Id IN ' );
      adoAwrdsQty.SQL.Add( ' ( SELECT EL_Id FROM Equipment_List WHERE
Plan_Id = '+sCurrPlanId+' )' );

So the parameters are being set as the loop is executed.

What if I saved all the information selected in my query and somehow just
copied it over to the dataset in a big update? Is this possible and would it
speed up execution?

"Mike Walsh" <techs.msllib.com@verizon.net> wrote in message
news:40a129c0$1@newsgroups.borland.com...
>
> "jpatton" <jppatton@vt.edu> wrote in message
> news:40a11b8b$1@newsgroups.borland.com...
> > The second from last line was supposed to be adoQuery1.Next; sorry about
> > that.
> >
> > What I have here is a grid that displays items. For each item there are
> two
> > quantity fields... one from the existing database and one from another
> > source. The purpose of the tool is to allow the user to choose which
> > quantity is correct and then update their existing database. I guess the
> > adoDataSet is a sort of temporary storage that updates a temporary table
> > however, this looping structure is what is taking so long.
> > I am not sure about the BatchOptimistic... etc. I am not familiar with
> > those. I was just asked to speed this up and identified this as the
> > bottleneck.
> >
>
> Like Vitali said originally, the looping is inefficient. You're retrieving
> information just to discard it and update with new values. I don't use
> sybase, but it should be similar to other DBMS for this to work. Since you
> say that the adoDataSet is opening a temp table, why not do something like
> (I'm using your component names for table names since I don't know them)
>
> insert into adoDataSet (Field1)
> select Something from adoTable1, adoTable where (somehow they relate)
>
> If there isn't a sybase temp table that you're updating, but instead some
> other thing that sybase can't access, then update your temp table with a
> parameterized insert statement.
>
> insert into adoDataSet (Field1) values (:Field1Value)
>
> As you loop thru your other datasets, simply set the parameter value, and
> execute the sql instead of opening it. You also might want to rethink the
> queries used in adoQuery1 and adoQuery2. You should be able to come up
with
> a single sql statement that will retrieve the records you want. Without
> knowing more information, I can't help with that
>
> Mike Walsh
>
>



Relevant Pages

  • Re: Performance enhancement
    ... > adoDataSet is a sort of temporary storage that updates a temporary table ... If there isn't a sybase temp table that you're updating, ... insert into adoDataSet (Field1) values ...
    (borland.public.delphi.database.ado)
  • Re: Indented Bill of Materials
    ... have no parent are inserted in a temp table, ... execution of the WHILE statement, the last executed statement is the SET ... In the first iteration, @lev will be increased to 1. ...
    (microsoft.public.sqlserver.programming)
  • Re: Indented Bill of Materials
    ... but eventually I will be calling SQL ... > have no parent are inserted in a temp table, ... > execution of the WHILE statement, the last executed statement is the SET ... > In the first iteration, @lev will be increased to 1. ...
    (microsoft.public.sqlserver.programming)
  • Re: SQL server 2005 Express - Vista - Invalid object name #spdbdesc
    ... #tableName refers to a temp table-- does it exist when you're doing this? ... the sproc execution automagically ... Used server manager to create user login with sysadmin role. ... my application executes the stored procedure "sp_helpdb" ...
    (microsoft.public.sqlserver.msde)
  • Re: Using temp tables
    ... you can store the data in Temporary tables or Physical ... The source for information on temp tables is - BOL- Books online is the best ... should be same as output of stored procedure. ... The difference is local temp tables are visible only to the execution. ...
    (microsoft.public.sqlserver.programming)