vvsrk76
asked on
SQL performnace...
The SQL is taking long time for me. Please help me in this.
SELECT Distinct CAT.CATENTRY_ID,
CAT.PARTNUMBER
FROM CATENTRY CAT
JOIN IMCCRP.IMC_ABC_PARTNO ABC ON CAT.CATENTRY_ID = ABC.CATENTRY_ID
JOIN IMCCRP.IMC_APPLICATION AN ON AN.APPLICATION_NUMBER = ABC.ABC_NO
JOIN IMCCRP.IMC_VEHICLE_MQT IVM ON IVM.BASEVEHICLEID = AN.BASE_VEHICLE_ID
WHERE IVM.MAKENAME = 'Honda'
Thanks for your time..
Thanks
Krishna
SELECT Distinct CAT.CATENTRY_ID,
CAT.PARTNUMBER
FROM CATENTRY CAT
JOIN IMCCRP.IMC_ABC_PARTNO ABC ON CAT.CATENTRY_ID = ABC.CATENTRY_ID
JOIN IMCCRP.IMC_APPLICATION AN ON AN.APPLICATION_NUMBER = ABC.ABC_NO
JOIN IMCCRP.IMC_VEHICLE_MQT IVM ON IVM.BASEVEHICLEID = AN.BASE_VEHICLE_ID
WHERE IVM.MAKENAME = 'Honda'
Thanks for your time..
Thanks
Krishna
ASKER
DB2 database.
Is Query looks ok?
Is Query looks ok?
Since your select looks valid, let's make sure you have the appropriate indexes (and primary keys) in place.
CATENTRY.CATENTRY_ID
IMC_ABC_PARTNO.CATENTRY_ID
IMC_ABC_PARTNO.ABC_NO
IMCCRP.IMC_APPLICATION.APP LICATION_N UMBER
IMCCRP.IMC_APPLICATION.BAS E_VEHICLE_ ID
IMC_VEHICLE_MQT.MAKENAME, IMC_VEHICLE_MQT.BASEVEHICL EID
Of course, you'd find A LOT of useful information on performance by doing a Visual Explain on the query.
Create those indexes (or ensure they already exist), do a Visual Explain, and report back to us how it works for you.
HTH,
DaveSlash
Regards,
DaveSlash
CATENTRY.CATENTRY_ID
IMC_ABC_PARTNO.CATENTRY_ID
IMC_ABC_PARTNO.ABC_NO
IMCCRP.IMC_APPLICATION.APP
IMCCRP.IMC_APPLICATION.BAS
IMC_VEHICLE_MQT.MAKENAME, IMC_VEHICLE_MQT.BASEVEHICL
Of course, you'd find A LOT of useful information on performance by doing a Visual Explain on the query.
Create those indexes (or ensure they already exist), do a Visual Explain, and report back to us how it works for you.
HTH,
DaveSlash
Regards,
DaveSlash
Also, how many rows are in each table, and how long does the query actually take to run?
ASKER
Thank you so much for time..
I have indexes on all tables..
IMC_APPLICATION table has 2 million records
IMC_ABC_PARTNO : 70K records
Catentry : 122K records
IMC_VEHICLE_MQT :14295 records
SQL execution time: 2 seconds.
I want to be reduce the sql execution time.We have so many calls for this query.I do not want to lock the tables for 2 sceonds. It is locking the other transactions..
I have indexes on all tables..
IMC_APPLICATION table has 2 million records
IMC_ABC_PARTNO : 70K records
Catentry : 122K records
IMC_VEHICLE_MQT :14295 records
SQL execution time: 2 seconds.
I want to be reduce the sql execution time.We have so many calls for this query.I do not want to lock the tables for 2 sceonds. It is locking the other transactions..
When you say "I have indexes on all tables", does that mean you have all the indexes I suggested?
Also, what did you find out when you did Visual Explain?
Also, what did you find out when you did Visual Explain?
Hi!
I would try these indexes if you don't have them.
On table IMC_ABC_PARTNO the index (CATENTRY_ID, ABC_NO)
On table IMC_APPLICATION the index (APPLICATION_NUMBER, BASE_VEHICLE_ID)
On table IMC_VEHICLE_MQT the index (MAKENAME, BASEVEHICLEID)
Having index on only one column is often not enough for complex queries.
Hope this helps.
Regards,
Tomas Helgi
I would try these indexes if you don't have them.
On table IMC_ABC_PARTNO the index (CATENTRY_ID, ABC_NO)
On table IMC_APPLICATION the index (APPLICATION_NUMBER, BASE_VEHICLE_ID)
On table IMC_VEHICLE_MQT the index (MAKENAME, BASEVEHICLEID)
Having index on only one column is often not enough for complex queries.
Hope this helps.
Regards,
Tomas Helgi
Hi vvsrk76,
It's been several days since we heard from you. Did you get your query to perform acceptably? If so, how?
-- DaveSlash
It's been several days since we heard from you. Did you get your query to perform acceptably? If so, how?
-- DaveSlash
ASKER
We are using the MQT's in DB2..
We are trying recreate the MQT.
We are trying recreate the MQT.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi, is this solved?
Will you please decide if your question is answered.
ASKER
Thank You
You need to add an index to the IVM.MAKENAME column