Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

insert and Modify

Former Member
0 Likes
6,835

Hi all,

Is there any different between INSERT and MODIFY in performance point .i.e. which one give the better performance if i want to insert record

Thanks

Tarak

9 REPLIES 9
Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
5,272

Hi,

If you are sure that no duplicate records exist in the table based on the primary keys, then INSERT statement will be gud.

But if you are not sure then you should always use MODIFY statement, else you will get a dump.

Check this link:-

Hope this helps you.

Regards,

Tarun

Edited by: Tarun Gambhir on Feb 27, 2009 3:40 PM

Read only

Former Member
0 Likes
5,272

Hi Tarak,

Please find the deifference between Insert and Modify as follows:

INSERT - It inserts the record at the end.

MODIFY - It finds first whether there is existing record with the key fields. If yes, then it modifies key fields else it also adds the record at the end.

If you want to add the new record always, then you should use insert record as it is performancewwise better than modify.

Regards,

Anil

Read only

Former Member
0 Likes
5,272

Hi,

There is no such similarity between these two:

INSERT we use generally to insert the data at any particular index or row. if we dont specify any index than it works similar as APPEND (adding in last row).

MODIFY we use to modify the statement at runtime.

It depends you requirement u need to judge which one u should use.

Ex: Like uploading data in excel sheet u need to insert column heading in index 1 of you internal table, there u dont do changes in the first row by using modify.

the same way if ur adding leading zero in ur integer fields than u need to modify not deleting that row and inserting the same row with added leading zero in integer fields.

Cheers,

Rudhir

Read only

former_member755502
Participant
0 Likes
5,272

Hi Tarak,

Usage of any of the statements i.e. INSERT, UPDATE and MODIFY depends on the requirement. e.g. INSERT doesnt allow duplicate entry, hence it will throw an exception if you try to insert a record which already exists. Whereas, MODIFY checks for record existence then if it doesnt find any matching record then it INSERTs or it simply UPDATEs the existing record. UPDATE is used to update existing record. So, you need to decide as per your requirement which statement you are going to use. But as you can see MODIFY can perform two things i.e. either INSERT or UPDATE (based on record existence check), so it can be costly in terms of performance if you think that your requirement can be fulfilled only with INSERT or UPDATE statement.

I think it will help.

Regards,

Sambaran Ray.

Read only

Former Member
0 Likes
5,272

>

> Is there any different between INSERT and MODIFY in performance point .i.e. which one give the better performance if i want to insert record

Hard to say since you haven't said whether you are working with database tables or internal tables.

Rob

Read only

Former Member
0 Likes
5,272

INSERT and MODIFY exist for Database and for internal table changes, but on he database both can insert lines/records. On internal tables MODIFY can only change the non-key fields of existing lines.

On database the MODIFY is a n Open SQL SQL statement and changed into an UPDATE or INSERT.

MODIFY is convenient for changes of a few records, when you don't know whether the reocrd is already there (must be updated) or not there (must be inserted).

For many records, i.e. performance-critical, you should use array changes i.e

INSERT ... FROM TABLE itab

or UPDATE ... FROM TABLE itab.

The MODIFY is not suitable for array-changes.

Siegfried

Read only

Former Member
0 Likes
5,272

Insert is used if you want to add new entry .. if you are sure that you always have new entry then use insert.

Modify is used when you want to modify existing entry, also it appends new entry when entry does not exist.

In case of performance if you want to append new entry then use insert which will be faster because in case of modify it will first search for the entry in the table.. and then if it does not find then it will insert.

If requirement is only to add new entry then must use INSERT (better performance marginally).

Regards,

Lalit Mohan Gupta.

Read only

Former Member
0 Likes
5,272

hi,

thanks for ur correction

regards

shivraj

Edited by: ShivrajSinha on Apr 22, 2009 12:24 PM

Read only

Former Member
0 Likes
5,272

> insert statement is used to insert some data at any particular index bt modify statement is used to

> make changes in already existing data,there is 1 more statement append wch is used to insert data > at d end so from performance point of view always use insert and not append.

please do me a favor, don't write about things where you know nothing, see other thread.

there is no APPEND on the database ... and the rest is also not correct.

> insert some data at any particular index

actually the opposite is true,

INSERT require workarea or tables, and can always use the primary key.

Siegfried