dbaspot
Tags Register FAQ Calendar Search Today's Posts Mark Forums Read

Update Problem - Oracle Server

This is a discussion on Update Problem - Oracle Server ; Hi I have this query to update some records in my table. It is working good but my problem is this query very slow. Is any way to do this job faster. UPDATE SWKPIFA Y SET Y.SWKPIFA_TRAN_CODE = 'G' WHERE ...



Reply

 

LinkBack Thread Tools Display Modes
  #1  
Old 12-12-2003, 11:49 AM
Database Bot
 
Join Date: Sep 2009
Posts: 1,236,254
Database Administrator is on a distinguished road
Default Update Problem

Hi

I have this query to update some records in my table. It is working
good but my problem is this query very slow. Is any way to do this job
faster.

UPDATE SWKPIFA Y
SET Y.SWKPIFA_TRAN_CODE = 'G'
WHERE SWKPIFA_START_TERM =
( SELECT MIN(X.SWKPIFA_START_TERM)
FROM SWKPIFA X
WHERE Y.SWKPIFA_PIDM = x.SWKPIFA_PIDM
AND Y.SWKPIFA_MAJR_CODE = X.SWKPIFA_MAJR_CODE)
AND SWKPIFA_END_TERM =
( SELECT MAX(X.SWKPIFA_END_TERM)
FROM SWKPIFA X
WHERE Y.SWKPIFA_PIDM = x.SWKPIFA_PIDM
AND Y.SWKPIFA_MAJR_CODE = X.SWKPIFA_MAJR_CODE)
/

Thanks
Hakim
Reply With Quote
  #2  
Old 12-12-2003, 12:10 PM
Database Bot
 
Join Date: Sep 2009
Posts: 1,236,254
Database Administrator is on a distinguished road
Default Re: Update Problem


"Mohammad" a écrit dans le message news:
cc59b627.0312120749.2e5984d4@posting.google.com...
> Hi
>
> I have this query to update some records in my table. It is working
> good but my problem is this query very slow. Is any way to do this job
> faster.
>
> UPDATE SWKPIFA Y
> SET Y.SWKPIFA_TRAN_CODE = 'G'
> WHERE SWKPIFA_START_TERM =
> ( SELECT MIN(X.SWKPIFA_START_TERM)
> FROM SWKPIFA X
> WHERE Y.SWKPIFA_PIDM = x.SWKPIFA_PIDM
> AND Y.SWKPIFA_MAJR_CODE = X.SWKPIFA_MAJR_CODE)
> AND SWKPIFA_END_TERM =
> ( SELECT MAX(X.SWKPIFA_END_TERM)
> FROM SWKPIFA X
> WHERE Y.SWKPIFA_PIDM = x.SWKPIFA_PIDM
> AND Y.SWKPIFA_MAJR_CODE = X.SWKPIFA_MAJR_CODE)
> /
>
> Thanks
> Hakim


Hello,
First of all, it could be a bit useful if you could tell the ng the version
of Oracle,
the OS and its version.
Second, nobody but you has even an idea of the DB you are running, what kind
of app it is,
how big are your tables, what are the indices and so on.
Plus, you could have posted the EXPLAIN PLAN along with your query.

Without any of these infos, one can't tell you anything except the fact that
running queries
with where clauses containing num_field=(select max(num_field) from
blahblah)
can be very long especially when main query and its sub queries are joined
together.

--
Alkos



Reply With Quote
  #3  
Old 12-12-2003, 12:10 PM
Database Bot
 
Join Date: Sep 2009
Posts: 1,236,254
Database Administrator is on a distinguished road
Default Re: Update Problem


"Mohammad" a écrit dans le message news:
cc59b627.0312120749.2e5984d4@posting.google.com...
> Hi
>
> I have this query to update some records in my table. It is working
> good but my problem is this query very slow. Is any way to do this job
> faster.
>
> UPDATE SWKPIFA Y
> SET Y.SWKPIFA_TRAN_CODE = 'G'
> WHERE SWKPIFA_START_TERM =
> ( SELECT MIN(X.SWKPIFA_START_TERM)
> FROM SWKPIFA X
> WHERE Y.SWKPIFA_PIDM = x.SWKPIFA_PIDM
> AND Y.SWKPIFA_MAJR_CODE = X.SWKPIFA_MAJR_CODE)
> AND SWKPIFA_END_TERM =
> ( SELECT MAX(X.SWKPIFA_END_TERM)
> FROM SWKPIFA X
> WHERE Y.SWKPIFA_PIDM = x.SWKPIFA_PIDM
> AND Y.SWKPIFA_MAJR_CODE = X.SWKPIFA_MAJR_CODE)
> /
>
> Thanks
> Hakim


Hello,
First of all, it could be a bit useful if you could tell the ng the version
of Oracle,
the OS and its version.
Second, nobody but you has even an idea of the DB you are running, what kind
of app it is,
how big are your tables, what are the indices and so on.
Plus, you could have posted the EXPLAIN PLAN along with your query.

Without any of these infos, one can't tell you anything except the fact that
running queries
with where clauses containing num_field=(select max(num_field) from
blahblah)
can be very long especially when main query and its sub queries are joined
together.

--
Alkos



Reply With Quote
  #4  
Old 12-12-2003, 12:10 PM
Database Bot
 
Join Date: Sep 2009
Posts: 1,236,254
Database Administrator is on a distinguished road
Default Re: Update Problem


"Mohammad" a écrit dans le message news:
cc59b627.0312120749.2e5984d4@posting.google.com...
> Hi
>
> I have this query to update some records in my table. It is working
> good but my problem is this query very slow. Is any way to do this job
> faster.
>
> UPDATE SWKPIFA Y
> SET Y.SWKPIFA_TRAN_CODE = 'G'
> WHERE SWKPIFA_START_TERM =
> ( SELECT MIN(X.SWKPIFA_START_TERM)
> FROM SWKPIFA X
> WHERE Y.SWKPIFA_PIDM = x.SWKPIFA_PIDM
> AND Y.SWKPIFA_MAJR_CODE = X.SWKPIFA_MAJR_CODE)
> AND SWKPIFA_END_TERM =
> ( SELECT MAX(X.SWKPIFA_END_TERM)
> FROM SWKPIFA X
> WHERE Y.SWKPIFA_PIDM = x.SWKPIFA_PIDM
> AND Y.SWKPIFA_MAJR_CODE = X.SWKPIFA_MAJR_CODE)
> /
>
> Thanks
> Hakim


Hello,
First of all, it could be a bit useful if you could tell the ng the version
of Oracle,
the OS and its version.
Second, nobody but you has even an idea of the DB you are running, what kind
of app it is,
how big are your tables, what are the indices and so on.
Plus, you could have posted the EXPLAIN PLAN along with your query.

Without any of these infos, one can't tell you anything except the fact that
running queries
with where clauses containing num_field=(select max(num_field) from
blahblah)
can be very long especially when main query and its sub queries are joined
together.

--
Alkos



Reply With Quote
  #5  
Old 12-12-2003, 04:44 PM
Database Bot
 
Join Date: Sep 2009
Posts: 1,236,254
Database Administrator is on a distinguished road
Default Re: Update Problem

Mohammad wrote:

> Hi
>
> I have this query to update some records in my table. It is working
> good but my problem is this query very slow. Is any way to do this job
> faster.
>
> UPDATE SWKPIFA Y
> SET Y.SWKPIFA_TRAN_CODE = 'G'
> WHERE SWKPIFA_START_TERM =
> ( SELECT MIN(X.SWKPIFA_START_TERM)
> FROM SWKPIFA X
> WHERE Y.SWKPIFA_PIDM = x.SWKPIFA_PIDM
> AND Y.SWKPIFA_MAJR_CODE = X.SWKPIFA_MAJR_CODE)
> AND SWKPIFA_END_TERM =
> ( SELECT MAX(X.SWKPIFA_END_TERM)
> FROM SWKPIFA X
> WHERE Y.SWKPIFA_PIDM = x.SWKPIFA_PIDM
> AND Y.SWKPIFA_MAJR_CODE = X.SWKPIFA_MAJR_CODE)
> /


Depending on lots of information you haven't given us, you might try ...

UPDATE SWKPIFA
SET Y.SWKPIFA_TRAN_CODE = 'G'
WHERE (SWKPIFA_PIDM,
SWKPIFA_MAJR_CODE,
SWKPIFA_START_TERM,
SWKPIFA_END_TERM) IN (
SELECT SWKPIFA_PIDM,
SWKPIFA_MAJR_CODE,
MIN(X.SWKPIFA_START_TERM),
MAX(X.SWKPIFA_END_TERM)
FROM SWKPIFA X
GROUP BY SWKPIFA_PIDM,
SWKPIFA_MAJR_CODE
)
/

--
Richard Kuhler

Reply With Quote
  #6  
Old 12-12-2003, 04:44 PM
Database Bot
 
Join Date: Sep 2009
Posts: 1,236,254
Database Administrator is on a distinguished road
Default Re: Update Problem

Mohammad wrote:

> Hi
>
> I have this query to update some records in my table. It is working
> good but my problem is this query very slow. Is any way to do this job
> faster.
>
> UPDATE SWKPIFA Y
> SET Y.SWKPIFA_TRAN_CODE = 'G'
> WHERE SWKPIFA_START_TERM =
> ( SELECT MIN(X.SWKPIFA_START_TERM)
> FROM SWKPIFA X
> WHERE Y.SWKPIFA_PIDM = x.SWKPIFA_PIDM
> AND Y.SWKPIFA_MAJR_CODE = X.SWKPIFA_MAJR_CODE)
> AND SWKPIFA_END_TERM =
> ( SELECT MAX(X.SWKPIFA_END_TERM)
> FROM SWKPIFA X
> WHERE Y.SWKPIFA_PIDM = x.SWKPIFA_PIDM
> AND Y.SWKPIFA_MAJR_CODE = X.SWKPIFA_MAJR_CODE)
> /


Depending on lots of information you haven't given us, you might try ...

UPDATE SWKPIFA
SET Y.SWKPIFA_TRAN_CODE = 'G'
WHERE (SWKPIFA_PIDM,
SWKPIFA_MAJR_CODE,
SWKPIFA_START_TERM,
SWKPIFA_END_TERM) IN (
SELECT SWKPIFA_PIDM,
SWKPIFA_MAJR_CODE,
MIN(X.SWKPIFA_START_TERM),
MAX(X.SWKPIFA_END_TERM)
FROM SWKPIFA X
GROUP BY SWKPIFA_PIDM,
SWKPIFA_MAJR_CODE
)
/

--
Richard Kuhler

Reply With Quote
  #7  
Old 12-12-2003, 04:44 PM
Database Bot
 
Join Date: Sep 2009
Posts: 1,236,254
Database Administrator is on a distinguished road
Default Re: Update Problem

Mohammad wrote:

> Hi
>
> I have this query to update some records in my table. It is working
> good but my problem is this query very slow. Is any way to do this job
> faster.
>
> UPDATE SWKPIFA Y
> SET Y.SWKPIFA_TRAN_CODE = 'G'
> WHERE SWKPIFA_START_TERM =
> ( SELECT MIN(X.SWKPIFA_START_TERM)
> FROM SWKPIFA X
> WHERE Y.SWKPIFA_PIDM = x.SWKPIFA_PIDM
> AND Y.SWKPIFA_MAJR_CODE = X.SWKPIFA_MAJR_CODE)
> AND SWKPIFA_END_TERM =
> ( SELECT MAX(X.SWKPIFA_END_TERM)
> FROM SWKPIFA X
> WHERE Y.SWKPIFA_PIDM = x.SWKPIFA_PIDM
> AND Y.SWKPIFA_MAJR_CODE = X.SWKPIFA_MAJR_CODE)
> /


Depending on lots of information you haven't given us, you might try ...

UPDATE SWKPIFA
SET Y.SWKPIFA_TRAN_CODE = 'G'
WHERE (SWKPIFA_PIDM,
SWKPIFA_MAJR_CODE,
SWKPIFA_START_TERM,
SWKPIFA_END_TERM) IN (
SELECT SWKPIFA_PIDM,
SWKPIFA_MAJR_CODE,
MIN(X.SWKPIFA_START_TERM),
MAX(X.SWKPIFA_END_TERM)
FROM SWKPIFA X
GROUP BY SWKPIFA_PIDM,
SWKPIFA_MAJR_CODE
)
/

--
Richard Kuhler

Reply With Quote
Reply

Thread Tools
Display Modes



All times are GMT -4. The time now is 06:54 PM.