Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 t-sql 2008 performance issue

Author  Topic 

jassie
Constraint Violating Yak Guru

332 Posts

Posted - 2013-09-14 : 17:43:00
I am having a performnace problem is a sql server 2008 sql. The stored procedure does a full table scan when one of the @state
or @zip paramteres are used. The dba says he will not put an index on the state and zip columns since this is the only sql that uses state and zip cocde. The sql look like the following:

select cs.person_id,cs.cust_id,cs.customer_name,cs.address1, cs.address2, cs.city, cs.cuct_id,z.product_name,z.product_description
from customer_table cs left join view1 v1 on v1.cust_id = cs.cust_id
left join
(select product_id,product_name,product_description from product_table p on p.iventory_id = v.iventory_id
where @prod_quantity <= p.supply_on_hand) z on z.person_id = c.person_id where @zip = Cs.zip or @state=cs.state

Thus can you tell me what I can do to make this sql run faster?
   

- Advertisement -