Sybase query optimization

Attached is my query which is taking very long, how can i optimize it?

Also attached are the indexes on the table

I cannot change any of the indexes on the table as i do not own the database.
-- Query to optimize
select A.BRANCH_CODE, A.CURRENCY_CODE, A.GL_CODE, A.CIF_SUB_NO, A.SL_NO, A.JV_REF,  
  CONVERT(VARCHAR, A.OP_NO) AS OP_NO, 
  A.DESCRIPTION, 
  ROUND(ABS(A.CV_AMOUNT), 2) AS CV_AMOUNT  
from  HST A
where 1=1  
AND A.COMP_CODE = 1  
and A.TRANS_DATE = '04/26/2010' 
AND A.GL_CODE != 199209  
AND A.GL_CODE != 705202  
AND A.GL_CODE != 199975  
AND A.LINE_NO != 0  
AND A.CREATED_BY = 'IMAL'  
AND ISNULL(A.REVERSAL_FLAG, 'N') = 'N'  
and A.JV_REF != 'FC REVALUE' ;

Open in new window

hst-index.xls
pixarsolAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jan FranekCommented:
Well, in my opinion, you are out of luck. I can't see any suitable index for your query and if you can't add new index (probably COMP_CODE, TRANS_DATE, CREATED_BY would help you most), your query will be slow.

By the way, you can remove 1 = 1 condition, but I don't think it will help you with your problem.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
pixarsolAuthor Commented:
I have updated my query a little and tried different combinations and i have come up with following which is pretty fast but as soon as i add another number 199975 in the clause ( AND A.GL_CODE not in (199209, 705202) ), it takes very long, why is that?


select A.BRANCH_CODE, A.CURRENCY_CODE, A.GL_CODE, A.CIF_SUB_NO, A.SL_NO, A.JV_REF,  
  CONVERT(VARCHAR, A.OP_NO) AS OP_NO, 
  A.DESCRIPTION, 
  ROUND(ABS(A.CV_AMOUNT), 2) AS CV_AMOUNT  
from  HST A
where A.COMP_CODE = 1  
and A.TRANS_DATE = '04/26/2010' 
AND A.CREATED_BY = 'IMAL' 
AND A.LINE_NO != 0  
AND A.GL_CODE not in (199209, 705202) 
AND ISNULL(A.REVERSAL_FLAG, 'N') = 'N'  
and A.JV_REF != 'FC REVALUE' ;

Open in new window

pixarsolAuthor Commented:
ok i optimized my query, thanks for your help :)
pixarsolAuthor Commented:
Thanks for your help
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Sybase Database

From novice to tech pro — start learning today.