Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Question about optimizing a query.

Status
Not open for further replies.

Sethington

Technical User
May 16, 2006
34
US
I have a query that is taking about 10 seconds to execute. I'm trying to optimize the query. Here is the code:

SELECT ACCOUNT_LEVEL,PROGRAM,ANNUAL_FEE, APR_FLOOR_RATE,CASH_ADV_RATE,LATE_FEE,NSF_FEE,APR_RATE,APR_BASIS,LATE_GRACE_DAYS,
DELINQ_MSG_MERCH,DELINQ_MSG_CASH,ACCRUAL_DATE,PAPER_GRADE,REQ_PC_ELIG,STRATEGY,
BANK,SYSTEM,PRINCIPLE,AGENT,APR_BASE_VALUE,CASH_ADV_FEE_RATE,DELINQ_PURCHASE_MARGIN_RATE,
DELINQ_CASH_MARGIN_RATE FROM BANK.VW_PRODUCT_CATALOG WHERE OFFER_CODE = ? AND CARD_TYPE=? WITH UR

My question is would this query run faster if I create a view that contains only the columns that I need and rewrite the query as:

SELECT * FROM BANK.VW_PRODUCT_CATALOG WHERE OFFER_CODE = ? AND CARD_TYPE=? WITH UR

Or
 
Seth,

If Offer_code and Card_type are in the index, then you will gain no performance increase by creating a view keyed on these columns. If they are not in an index, then you probably would, but you'd be better off adding and index to the table based on those columns.

Marc
 
10 seconds seems a pretty long time if indices do exist. Proper use of indices should give almost instanteneous results for such a straightforward query. Depending on the cardinality of offer_code and card_type, you should check out alternatives to regular B-tree indices.


Ties Blom
 
Thanks for your input. I think better indexing will fix our situation. I know some of these columns are already indexed but I think they are indexed too many times and not properly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top