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)
 Select Query Optimization

Author  Topic 

Deathnote
Starting Member

4 Posts

Posted - 2012-02-12 : 21:26:35
Guyz Im new to sql and hope you guyz can help me. Ok i have 2 queries getting data from the same table and same parameters. The problem is one takes less than a second to give results and the other takes 7 minutes!!!

heres the first and the faster one

SELECT Distinct Kataban
FROM SFA_Data
WHERE Seiban='96609c' and Inspection_Type_ID='P' order by Kataban


SELECT Distinct Lens_Type
FROM SFA_Data
WHERE Seiban='96609c' and Inspection_Type_ID='P' order by Lens_Type


can someone pls explain why this happens and how i can optimize the second query? tnx

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-02-12 : 23:41:57
which are indexes present in the table?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -