Inserting multiple records in multiple tables - High Performance
I have a input form in the table and the user can input any no. of rows. Every row has around 25 columns and when a single row is saved, each of this column is saved in its own table, i.e. there are 25 inserts happening (for 25 columns) for a single row. Now if a user paste even 100 rows this takes a lot of time (because of 100*25 inserts happening). Now I want to support 10000 inserts and obviously it should be very fast. Can someone tell me how to maximize the performance. I am using mysql 4.1 as my DB.
javanewbie80 wrote:
I have a input form in the table and the user can input any no. of rows. Every row has around 25 columns and when a single row is saved, each of this column is saved in its own table, Why is each value its own table? Are they not related in some way?
This sounds like a bad RDBMS design.
i.e. there are 25 inserts happening (for 25 columns) for a single row. Now if a user paste even 100 rows this takes a lot of time (because of 100*25 inserts happening). Now I want to support 10000 inserts and obviously it should be very fast. Can someone tell me how to maximize the performance. I am using mysql 4.1 as my DB.
Rethink your design.
If you must persist in this folly, I'd recommend batching your INSERTs to try and minimize network traffic.
But do consult with somebody who actually knows SQL and relational design. This smells bad.
%
Similar Messages
-
Insert multiple records into a table(Oracle 9i) from a single PHP statement
How can I insert multiple records into a table(Oracle 9i) from a single PHP statement?
From what all I've found, the statement below would work if I were using MySQL:
insert into scen
(indx,share,expire,pitch,curve,surface,call)
values
(81202, 28, 171, .27, 0, 0, 'C' ),
(81204, 28, 501, .25, 0, 0, 'C' ),
(81203, 17, 35, .222, 0, 0, 'C' ),
(81202, 28, 171, .27, 2, 0, 'C' ),
(81204, 28, 501, .20, 0, 1, 'C' ),
(81203, 28, 135, .22, 1, 0, 'C' )
The amount of records varies into the multiple-dozens. My aim is to utilize the power of Oracle while avoiding the i/o of dozens of single-record inserts.
Thank you,
WillYou could look at the INSERT ALL statement found in the documentation here:
http://download.oracle.com/docs/cd/B10501_01/server.920/a96540/statements_913a.htm#2133161
My personal opinion is that you probably won't see any benefit because under the hood I think Oracle will still be doing single row inserts. I could be wrong though.
The only way to confirm was if you did a test of multiple inserts vs an INSERT ALL, that is if the INSERT ALL met your requirements.
HTH. -
Inserting Multiple Records into two table
I want to insert records from a ADF swing form into two tables. In the first table the primary key is generated by a trigger and then I need to retrieve the primary id generated and then insert multiple records in another table using the primarykey obtained from the first table as foreign key.
How to do this ?User,
If you're using ADF Business components, have a read on the DBSequence data type. If you have two VO's linked by a view link, and the FK is a DBSequence type, all this happens for you out-of-the-box.
Hope this helps,
john -
Multiple record update in TABLE Control.
Hi All,
I m developing dialog program with table control.
I want to know how to update multiple records through the table control if user selects more than one.
Also depending on some condition i want to change the status of one reocrd and not the column as a display field and won't be editable. I have tried with loop at screen and modify screen, but it is showing the whole column as display only.
ANy solution let me knowHi,
pls chk this standard pgms.
for examples on table control
demo_dynpro_tabcont_loop
demo_dynpro_tabcont_loop_at
RSDEMO_TABLE_CONTROL
chk a sample code.
DATA :BEGIN OF int_table OCCURS 0,
fld1 TYPE ztable-fld1,
fld2 TYPE ztable-fld2,
fld3 TYPE ztable-fld3,
chk(1),
END OF int_factor.
*write the blow code in PAI
LOOP AT int_table WHERE chk = 'X'.
*modify the data base table
MODIFY ztable FROM int_table. "from header
clear int_table
ENDLOOP.
regards
Anver -
Allow multiple records from this table to be displayed in the form is greyed out.
I'm trying to add a second table to my main data source in an InfoPath 2010 form (database template), but the option to allow multiple records from this table to be displayed in the form is greyed out and I can't select it.
Can someone please tell me how to correct this? I'm guessing that there might have to be something change in MS SQL because on other occasions I've have not encountered this problem when adding a second table.
Any help would be greatly appreciated.
Thanks.So I've found a work around, but I still don't know why I'm having the problem in the first place.
I've been trying to relate the two tables by using the primary key in the parent table to a view of the child table that also includes primary key in the parent, e.g. the ORDER ID in the order table relating to the ORDER ID in the view of the order detail
table. For whatever reason whenever I did that InfoPath prohibited the data source from returning multiple order details.
My work around is to use views of both the order table and order details table that include the customer ID and to relate the two table in InfoPath using the customer ID. Now I get a data source that allows multiple order detail records. In order to get
just the order details that I want that relate to a particular order, I use a rule that sets the order id in both the order and order details query data sets before executing the query (as opposed to just the order data set).
Hope that's a clear explanation. -
Error in inserting a record in to table
hi..
i created a trigger....when i am trying to insert new record in to table i am getting the fallowing error...plz kindly help me out from this...
SQL> create or replace trigger secure_emp
2 before insert on employees begin
3 if(to_char('sysdate','DY') in ('SAT','SUN')) or
4 (to_char('sysdate','HH24:MI') not between '8:00' and '18:00') then
5 raise_application_error(-20500,'error');
6 end if;
7 end;
8 /
Trigger created.
SQL> insert into employees(employee_id,last_name,first_name,email,hire_date,job_id,salary,department
_id)
2 values (300,'smith','jack','SJACK',sysdate,'IT_PROG',4500,60);
insert into employees(employee_id,last_name,first_name,email,hire_date,job_id,salary,department_id)
ERROR at line 1:
ORA-06502: PL/SQL: numeric or value error: character to number conversion error
ORA-06512: at "SCOTT.SECURE_EMP", line 2
ORA-04088: error during execution of trigger 'SCOTT.SECURE_EMP'Yeah. Whenever Oracle sees TO_CHAR('string_literal1', 'string_literal2), it implicitly converts it to TO_CHAR(TO_NUMBER('string_literal1'), 'string_literal2). That's why an error in trigger occurs.
SQL> explain plan for
2 select null
3 from dual
4 where dummy = to_char('A', 'DY');
Explained
SQL> @utlxpls
Cannot SET MARKUP
PLAN_TABLE_OUTPUT
Plan hash value: 397561404
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 2 | 2 (0)| 00:00:01 |
|* 1 | TABLE ACCESS FULL| DUAL | 1 | 2 | 2 (0)| 00:00:01 |
Predicate Information (identified by operation id):
1 - filter("DUMMY"=TO_CHAR(TO_NUMBER('A'),'DY'))
13 rows selected -
Abort inserting a record in a table using a trigger
Hi there,
Is there any way to abort inserting a record in a table using a trigger?
For full details, I have the following table ("myTable"):
BSC INTEGER NOT NULL,
BTS VARCHAR2(20) NOT NULL,
INFO1 INTEGER,
INFO2 INTEGER
myTable_PK = PRIMARY KEY (BSC,BTS)
I have also a stored procedure that imports a data from text file and inserts them to the specified table (using UTL_FILE package). The stored procedure works great.
But the thing that in the text file itselft it might be (due to third-parity report generation bug) that the primary key will be violated or the BSC/BTS field has null value. In such case I just want to ignore the insertion statement using a trigger.
ThanksOk Jens, could you tell me what exception could I use?
Below a protion of my StoredProcedure.
CREATE OR REPLACE PROCEDURE update_myTable() IS
FHANDLE UTL_FILE.FILE_TYPE;
BSC INTEGER;
BTS VARCHAR2(20);
INFO1 INTEGER;
INFO2 INTEGER;
BEGIN
FHANDLE := UTL_FILE.FOPEN('LOG_FILE_DIR',FILENAME,'R',4000);
LOOP
UTL_FILE.GET_LINE(FHANDLE,STR);
-- Process the line STR and generates BSC, BTS, INFO1, and INFO2 values
EXECUTE IMMEDIATE 'INSERT INTO myTable VALUES(:1,:2,:3,:4)' USING BSC,BTS,INFO1,INFO2;
END LOOP;
EXCEPTION WHEN NO_DATA_FOUND THEN UTL_FILE.FCLOSE(FHANDLE);
END UPDATE_R205BTS;
Remember that I am already using an exception with NO_DATA_FOUND to indicate the end of file then closing it.
Thanks for your reply -
Triggers to insert the record in a table
I have two table 1. Holiday 2. Attendance.
When I insert the record in holiday table for his
advance holiday with empid, the same time I want to insert it attendance table
automatically for the same date using a trigger
Insert into attendance (empid,date,holiday) values (20078,07/10/2014,1). If holiday column value 1 represent holiday marked,
0 represent holiday not marked. The same thing can happen vice versa
If employee mark his current attendance as holiday through attendance,
it should be inserted into holiday table
automatically using triggers.
Insert into Holiday (empid,date,holiday) values (20078,06/08/2014,1). If holiday column value 1 represent holiday marked,
0 represent holiday not marked. The same thing can happen vice versa
Please I am looking for your help , how I can make it using triggers
to insert both table in two different ways of options.
Regards
Pol
polachanHi polachan,
According to your description, if you want to synchronize the data between the holiday table and the attendance table while inserting records into holiday table, you need to create a trigger on the holiday table, please try the following syntax.
use <databasename>
go
create trigger Tr_holiday
on holiday
for insert
as
declare @empid varchar(20),
@date datetime,
@holiday int
select @empid = empid, @date=date, @holiday=holiday from inserted
declare @qty int
select @qty =count(*) from attendance where empid=@empid and date=@date and holiday=@holiday
if @qty<1
begin
insert into attendance
select i.empid,
i.date,
i.holiday
from inserted i
end
Meanwhile, if you want to insert the record into the holiday table when holiday is updated to 1 in the attendance table, you need to create another trigger on the attendance table, please try the following syntax.
use <databasename>
go
create trigger Tr_attendance
on attendance
for update
as
declare @holiday int
if update (holiday)
begin
select @holiday=holiday from inserted
if @holiday=1
begin
insert into dbo.holiday
select empid,
date,
holiday
from inserted
end
end
For more details about creating triggers in SQL Server, please review this article:
CREATE TRIGGER (Transact-SQL).
Thanks,
Lydia Zhang -
How to insert a record in ROOSPRMSC table? (accidentally deleted)
Calling an InfoPackage in BW causes short dump, while fixing the short dump issue, accidentally
deleted the "ROOSPRMSC" table entries.
Could you tell me how to insert a record in "ROOSPRMSC" table???Hi Senthil,
Regards,
Phani Raj Kallur
Message was edited by: Phani Raj Kallur -
Inserting new records into database table at runtime
Hi all ,
How to insert new records into database table at runtime on click update?
Thanks.Hi Sasikala,
Just for your understanding am giving a sample code snippet which you can use to read the contents of your Table UI element & save the data on to your database. Suppose you have a button up on pressing which you want to read the data from your screens table & save on to the database then you can proceed as shown below:
1) Obtain the reference of your context node.
2) Fetch all the data present in your table into an internal table using methods of if_wd_context_node
3) Use your normal ABAP logic to update the database table with the data from your internal table
In my example I have a node by name SFLIGHT_NODE and under this I have the desired attributes from SFLIGHT. Am displaying these in an editable table & the user would press up on a push button after making the necessary changes to the tables data. I would then need to obtain the tables information & save on to the database.
data: node_sflight type ref to if_wd_context_node,
elem_sflight type ref to if_wd_context_element,
lt_elements type WDR_CONTEXT_ELEMENT_SET,
stru_sflight type if_main=>element_sflight_node,
it_flights type if_main=>elements_sflight_node.
" navigate from <CONTEXT> to <SFLIGHT_NODE> via lead selection
node_sflight_node = wd_context->get_child_node( name = 'SFLIGHT_NODE' ).
lt_elements = node_sflight->get_elements( ).
" Get all the rows from the table for saving on to the database
loop at lt_elements into elem_sflight.
elem_sflight->get_static_attributes( importing static_attributes = stru_sflight ).
append stru_sflight to it_flights.
endloop.
" Finally save the entries on to the database
modify ZSFLIGHT99 from table it_flights.
if sy-subrc eq 0.
endif.
However a word of caution here.... SAP doesn't ever recommend directly modifying the database through an SQL query. You would preferably make use of a BAPI for the same. Try go through Thomas Jung's comments in [here|modify the data base table which is comming dynamiclly;.
Regards,
Uday -
Splitting of a CSV File with Multiple Records into Multiple XML File
Dear All,
<b> I am doing a Scenario of CSV to XML Files. I am using BPM for the same. My incoming CSV File has got multiple records. I want to break this Multiple records into Multiple XML Files having one record each.</b>
Can someone suggest how can I break this rather Split this into Multiple XML Files.
Is Multimapping absoltely necesaary for this. Can't we do this without Multimapping. Can we have some workaround in the FCC parameters that we use in the Integration Directory.
Kindly reply ASAP. Thanks a lot to all in anticipation.
Pls Help.
Best Regards
Chakra and SomnathDear All,
I am trying to do the Multimapping, and have 0....unbounded also. Someways it is not working.
<b>
Smitha please tell me one thing...Assigning the Recordsets per Message to 1, does it mean that it will write multiple XML Files as I want.</b>
Also I am usinf Set to Read only. So once the File is read it becomes RA from A. Then will it write the other Records.
I have to use a BPM because there are certain dependencies that are there for the entire Process Flow. I cannot do without a BPM.
Awaiting a reply. Thanks a lot in anticipation.
Best Regards
Chakra and Somnath -
Inserting Multiple Records in Transparent Table
Hi Friends,
I am New to ABAP and Previously i was in Web Dynpro Java....
I am doing an scenario Travel Request.
The Problem i am facing i this scenario is inserting the data in the table. I have to maintain a custom table in which Travel request No (Primary Key), Employee No (Primary Key) and Transport Details.....etc.are maitained...
Employee Number -
Travel Request No--Place From-Place To
70043 -
817--Chicago--
Miami
70043 -
817--Miami--
Chicago
I have to maintain table like this
Whenever i inseted the data into the Tranparent Table its showing dump and sy-subrc count is 4
Plz provide suggestion to achieve this........Thanks in Advance
Regards
Chandran SIn ur case u r trying to enter duplicate values that's why u r getting error.
In ur custom table, Employee Number and Travel Request No are 2 primary keys. That means for each record content of these fields should be unique but in ur case they are same. If u really need to maintain data in this way then u have to make another field as key field so that it can uniquely identify a record.
Employee Number Travel Request No Place From Place To
70043 817 Chicago Miami
70043 817 Miami Chicago
Regards,
Joy. -
Inserting multiple records in a table through detail block
hi,
i am new to oracle forms. i want to enter more than one records in a table through a master detail forms.
the records will be entered by user in the detail section. can any ody help me?Hi Lance,
Try creating records in detail block in the when new block instance trigger of
detail block. Set the validation unit property of the form to FORM before trying this.
Hope this might be helpful to you.
V.Senthil Kumar -
Insert Multiple Records into Multiple ZTABLEs inside the BAPI
Hi,
I have a requirement to Insert or Update Multiple Records into a ZTABLE inside the BAPI. Is there any special approach inside the BAPI to insert or update ZTABLEs with multiple records. It looks like the simple INSERT Statement is not working. Can you please suggest me a Suitable solution for this req?
Thanks and Regards,
KannanHi,
INSERT ZTABLE FROM TABLE ITAB.
The itab structure should be of the structure ZTABLE..
Same for MODIFY and update.
MODIFY ZTABLE FROM TABLE ITAB..
Thanks,
Naren -
To load multiple records in multiple target tables
I have to read multiple records as a set from a single source flat file and load into different target tables.
I have to read 3 records as a set and load into 3 different target tables and read another 3 records as a set and load into previous 3 target tables and it goes on
till all the records from the flat file are loaded.
The structure of the file is as follows:
Header Record
Line Record
Distribution Record
Header Record
Line Record
Distribution Record
Read Header Record and load into target table A
Read Line Record and load into target table B
Read Distribution Record and load into target table C
--- repeat the same steps till all records are read and loaded into target tables.
I would appreciate if anyone can suggest the best approach of designing interface/package and error conditions to handle ?
Thanks,
RamHi,
in this case you must create datastore under a 'Flat file' model
Create for example 3 datastore with the same ressource (file) but change defintion of column
Generaly on the first column, define the 'pattern' for each specific format 'variable code'
You must create 3 interfaces and load your target (databse table for example)
Regards
Stephane -
Load multiple records in 1 table from 1 line in text file w/sql loader
hi guys,
quick question, perhaps someone can help. searched around and didn't see this question asked before, and can't find any answer in SQL Loader faqs or docs.
i know i can extract multiple logical records from a single physical record in the input file as two logical records, and then use two into tables clauses to load the data into the table. see oracle 9i sql loader control file reference chapter 5 to see what i am talking about.
but my question follows:
cust_id amount1_val amount1_qual amount2_val amount2_qual amount3_val amount3_qual
123 1500.35 TA 230.34 VZ 3045.50 TW
basically i want to use one sql loader statement to load these 3 records into 1 table. the issue for me is that i need to re-use the cust_id for all 3 records as the key, along with the qualifier code. the example in the Oracle docs only works for data where the logical records are completely separate -- no shared column values.
i'm sure this is possible, perhaps using some :cust_id type parameter for the 2nd and 3rd records, or something, but i just don't have enough knowledge/experience with sql loader to know what to do. appreciate any help.
wayneHi wayne,
I found an example on what exactly you were looking for from an SQL*Loader documentation. Please see if it of some help to you
EXAMPLE
The control file is ULCASE5.CTL.
1234 BAKER 10 9999 101
1234 JOKER 10 9999 777
2664 YOUNG 20 2893 425
5321 OTOOLE 10 9999 321
2134 FARMER 20 4555 236
2414 LITTLE 20 5634 236
6542 LEE 10 4532 102
2849 EDDS xx 4555
4532 PERKINS 10 9999 40
1244 HUNT 11 3452 665
123 DOOLITTLE 12 9940
1453 MACDONALD 25 5532
In the above datafile
Column1 - Empno
Column2 - ENAME
Column3 - Depno.
Column4 - MGR
Column5 - Proj no.
-- Loads EMP records from first 23 characters
-- Creates and loads PROJ records for each PROJNO listed
-- for each employee
LOAD DATA
INFILE 'ulcase5.dat'
BADFILE 'ulcase5.bad'
DISCARDFILE 'ulcase5.dsc'
1) REPLACE
2) INTO TABLE emp
(empno POSITION(1:4) INTEGER EXTERNAL,
ename POSITION(6:15) CHAR,
deptno POSITION(17:18) CHAR,
mgr POSITION(20:23) INTEGER EXTERNAL)
2) INTO TABLE proj
(empno POSITION(1:4) INTEGER EXTERNAL,
3) projno POSITION(25:27) INTEGER EXTERNAL) -- 1st proj
Notes:
REPLACE specifies that if there is data in the tables to be loaded (EMP and PROJ), SQL*loader should delete the data before loading new rows.
Multiple INTO clauses load two tables, EMP and PROJ. The same set of records is processed three times, using different combinations of columns each time to load table PROJ.
Regards,
Murali Mohan
Maybe you are looking for
-
My ipod wont turn on unless on charge! :(
my ipod wont turn on anymore. i droppped it at the gym and now the only time it works is when it is on charge. i can't even connect it to iturns on my PC:( when its connected to the charger i can play a song but as soon as i unplug it it goes off aga
-
i got mugged and the guy took my iphone 3G, the "find my iphone" app wasnt installed, so, there's a way to locate it without the app???
-
Where is the window that displays midi chord names played on my controller??
I can't seem to locate the pane in the transport window that displays chords/notes played on the midi controller that was present in past versions. Any ideas, please????
-
Problems with iwork09 opening on my new macbookair
I have a problem with opening iwork09 on my new mac book air. I didnt purchase it online, i had the installing CD and it worked great on my old mac, now I moved it from the old one to the new one and even after the update, when I try to open the page
-
What is GameCenter APP and how did it get on my phone?
Hello all, I can't seem to delete it and have no knowledge of how it got on my phone. I never established an account. Thanks, Al