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
 General SQL Server Forums
 New to SQL Server Programming
 query

Author  Topic 

gagani
Posting Yak Master

112 Posts

Posted - 2013-12-16 : 07:58:13
I need a query which retrives the firstnames of the person where last name is john. I am considering the performance as the main factor.

Is there any better query than the following?

Select firstname from tablename where lastname='John'

could anyone please answer considering performance as the major factor

ahmeds08
Aged Yak Warrior

737 Posts

Posted - 2013-12-16 : 08:22:04
have an index on lastname column.

mohammad.javeed.ahmed@gmail.com
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-12-16 : 10:19:16
you may even create an index with (firstname,lastname) so that it covers the full query

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -