Append v. Insert Speed Q. 
Author Message
 Append v. Insert Speed Q.

Which is faster as far as processing the data, Append from ??? or Insert
Into ?

Tia,

Jonathan Morningstar



Sun, 23 Feb 2003 00:35:24 GMT  
 Append v. Insert Speed Q.
My limited testing indicates that Insert is faster, but they are both so
fast that unless you are adding thousands of records it probably doesn't
make any difference. I prefer Append because it is more readable:

APPEND BLANK
REPLACE THIS WITH THAT
REPLACE THIS WITH THAT
REPLACE THIS WITH THAT

versus

INSERT INTO MYTABLE (FIELD1, FIELD2, FIELD3) VALUE (VALUE1, VALUE2, VALUE3)

I'd rather have a dozen lines of readable code than one long runon line that
isn't qute as readable.


Quote:
> Which is faster as far as processing the data, Append from ??? or Insert
> Into ?

> Tia,

> Jonathan Morningstar



Sun, 23 Feb 2003 00:59:07 GMT  
 Append v. Insert Speed Q.

A related side question...In the testing did you do as indicated below (with
multiple replace statements)?  I long ago did some testing (back in FPW) on
REPLACE and found that most of the overhead was in the command itself rather
than the write time, if that makes sense.  So...

REPLACE A WITH 1, ;
        B WITH 2, ;
        C WITH 3

was nearly three times faster than

REPLACE A WITH 1, ;
REPLACE B WITH 2, ;
REPLACE C WITH 3

Just a thought,

John


Quote:
> My limited testing indicates that Insert is faster, but they are both so
> fast that unless you are adding thousands of records it probably doesn't
> make any difference. I prefer Append because it is more readable:

> APPEND BLANK
> REPLACE THIS WITH THAT
> REPLACE THIS WITH THAT
> REPLACE THIS WITH THAT

> versus

> INSERT INTO MYTABLE (FIELD1, FIELD2, FIELD3) VALUE (VALUE1, VALUE2,
VALUE3)

> I'd rather have a dozen lines of readable code than one long runon line
that
> isn't qute as readable.



> > Which is faster as far as processing the data, Append from ??? or Insert
> > Into ?

> > Tia,

> > Jonathan Morningstar



Sun, 23 Feb 2003 03:22:37 GMT  
 Append v. Insert Speed Q.
For readability you can also do:

m.Field1 = "Some Value"
m.Field2 = "Some other Value"

INSERT INTO MyTable FROM MEMVAR

One thing no one has mentioned -
APPEND BLANK adds a blank record and changes the indexes to reflect the new
values.
REPLACE.... changes values and changes the indexes to reflect the new
values.

INSERT INTO changes values and changes the indexes to reflect the new
values.  (Note that the index is only changed once with this statement !!!)

If you are adding a huge amount of data it is sometimes faster to drop all
of the indexes, add the data, and reindex.  (But I think you were referring
to one record at a time.)

--

Cindy Winegarden
Microsoft Certified Professional, Visual FoxPro

Duke Children's Information Systems
Duke University Medical Center


| My limited testing indicates that Insert is faster, but they are both so
| fast that unless you are adding thousands of records it probably doesn't
| make any difference. I prefer Append because it is more readable:
|
| APPEND BLANK
| REPLACE THIS WITH THAT
| REPLACE THIS WITH THAT
| REPLACE THIS WITH THAT
|
| versus
|
| INSERT INTO MYTABLE (FIELD1, FIELD2, FIELD3) VALUE (VALUE1, VALUE2,
VALUE3)
|
| I'd rather have a dozen lines of readable code than one long runon line
that
| isn't qute as readable.
|
|

| > Which is faster as far as processing the data, Append from ??? or Insert
| > Into ?
| >
| > Tia,
| >
| > Jonathan Morningstar
| >
| >
|
|



Sun, 23 Feb 2003 08:11:53 GMT  
 Append v. Insert Speed Q.

This would make sense, every instance of REPLACE will lock the record so it
can update it. So if you only have one replace, you only lock the record
once where as if you have three replaces you lock and unlock the record
three times.

John


Quote:
> A related side question...In the testing did you do as indicated below
(with
> multiple replace statements)?  I long ago did some testing (back in FPW)
on
> REPLACE and found that most of the overhead was in the command itself
rather
> than the write time, if that makes sense.  So...

> REPLACE A WITH 1, ;
>         B WITH 2, ;
>         C WITH 3

> was nearly three times faster than

> REPLACE A WITH 1, ;
> REPLACE B WITH 2, ;
> REPLACE C WITH 3

> Just a thought,

> John



> > My limited testing indicates that Insert is faster, but they are both so
> > fast that unless you are adding thousands of records it probably doesn't
> > make any difference. I prefer Append because it is more readable:

> > APPEND BLANK
> > REPLACE THIS WITH THAT
> > REPLACE THIS WITH THAT
> > REPLACE THIS WITH THAT

> > versus

> > INSERT INTO MYTABLE (FIELD1, FIELD2, FIELD3) VALUE (VALUE1, VALUE2,
> VALUE3)

> > I'd rather have a dozen lines of readable code than one long runon line
> that
> > isn't qute as readable.



> > > Which is faster as far as processing the data, Append from ??? or
Insert
> > > Into ?

> > > Tia,

> > > Jonathan Morningstar



Sun, 23 Feb 2003 15:28:48 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Loads of Data, Form Load Speed Q.

2. Insert/Overtype Q.

3. Memo Field Q. on Inserting Text...

4. Q. on searching and inserting data

5. Append Q.

6. How to speed append from with CDX???

7. What append with speed of VFP 7???????

8. APPEND/INSERT from .dbf to Remote View

9. Insert Into vs Append Blank/Gather MemVar

10. Append/Insert memo field data

11. Append/Insert/Import?

12. Insert vs Append when Updating View

 

 
Powered by phpBB® Forum Software