View previous topic :: View next topic
|
Author |
Message |
krsenthil85
New User
Joined: 31 Aug 2007 Posts: 55 Location: bangalore
|
|
|
|
Hi all,
I am having a requirement to reduce the run time for the job. Using strobe tool i found that one of the query involved in the program is taking time. The query is
INSERT
INTO Table1
SELECT *
FROM Table2
WHERE Col1 = xxxx
AND col2 = 0
Here the subquery is having around 1000's of rows. Please help me to reduce the time for this query in developer point of view and also from dba point of view. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello krsenthil85 and welcome to the forums,
How many rows does this process INSERT? Are Col1 and col2 defined as a key in table2? If the process has to do a full table scan to find the matches, that will waste resources.
How much time is it taking? Depending on how many thousands of rows are inserted, the time it takes may be reasonable.
It may help if you clarify the difference between developer and dba "point of view". |
|
Back to top |
|
|
vebs
New User
Joined: 27 Oct 2007 Posts: 19 Location: UK
|
|
|
|
There might be two places where you can look for optimization -
a) First one, like Dick suggested, you can check the select query for performance, to reduce time taken. This includes checking for Indexscan, clustering etc.
b) Second, since your job is loading thousands of rows, you can consider changing the INSERT to LOAD. This will reduce time elapsed significantly.
Also, if due to some incorrect INSERT operation, you recieve non-zero SQLCODE, then I believe your job will abend and rest of the rows will also not be loaded until you restart it.
But if you consider using LOAD, all the rows will be loaded EXCEPT those which were invalid, giving you better control on the process. You can later choose to reject those rows, or correct and load them, but your process will not come to a halt. |
|
Back to top |
|
|
krsenthil85
New User
Joined: 31 Aug 2007 Posts: 55 Location: bangalore
|
|
|
|
Hi Dick,
Thanks for your description. The answer for your question is, this table is having one of the column as a key value.
I mean Difference b/w developer and DBA point of view is modications on the query is developer task and changing the structure of the table or index is DBA point.
Please let me know if you need more details on this. |
|
Back to top |
|
|
|