Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #11 (permalink)  
Old January 10th, 2008, 01:41 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Hudson, MA, USA.
Posts: 839
Thanks: 0
Thanked 1 Time in 1 Post
Default

Quote:
quote:Originally posted by rstelma
 So, use your correctly constructed queries to build your indexes.
Therein lies the rub. It isn't always that simple to correctly construct a query.

Just to contrive an example, let's say you have a table of Person rows with a DateOfBirth column with an index on that column and you want to select the rows where the person is older than 21. (I know the following isn't really a correct age calculation - I said this was contrived :))

A WHERE clause such as:

    WHERE DATEDIFF(yy, DateOfBirth, GETDATE()) > 21

will not use the index, whereas:

    WHERE DateOfBirth < DATEADD(yy, -21, GETDATE())

will.

So, even though both forms will be "correct", in that they return the same resultsets, only the second is able to make use of an index. If you think you have a performance problem with a query, you really need to examine the query plan to see what's going on, and define indexes so as to influence the plan favorably. If you create an index, and the plan doesn't change, then you need to understand why. You don't want to create indexes just "because" - there should be a definitive reason why you do, i.e. the query processor actually makes use of the index...

Jeff Mason
je.mason@comcast.net
Reply With Quote
  #12 (permalink)  
Old January 10th, 2008, 03:21 PM
Friend of Wrox
Points: 2,101, Level: 18
Points: 2,101, Level: 18 Points: 2,101, Level: 18 Points: 2,101, Level: 18
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2003
Location: , , .
Posts: 599
Thanks: 6
Thanked 3 Times in 3 Posts
Default

That makes sense. Why build a bridge to nowhere? Or why build a bridge when you don't have a car? Or a donkey?

Reply With Quote
  #13 (permalink)  
Old January 10th, 2008, 05:14 PM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Quote:
quote:Or why build a bridge when you don't have a car?
To let other cars come into your village so you can get out of the hell hole?? ;)

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
Reply With Quote
  #14 (permalink)  
Old January 10th, 2008, 08:34 PM
Friend of Wrox
Points: 2,101, Level: 18
Points: 2,101, Level: 18 Points: 2,101, Level: 18 Points: 2,101, Level: 18
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2003
Location: , , .
Posts: 599
Thanks: 6
Thanked 3 Times in 3 Posts
Default

Yeah, I'm getting a donkey. Gas is getting too expensive. Talk about bio-fuel!!!

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
select statement ??? RinoDM SQL Server 2000 7 June 19th, 2008 08:40 AM
select Statement gregalb SQL Server 2000 3 January 15th, 2008 12:00 AM
Select from another select statement to a repeater simsen ASP.NET 2.0 Professional 0 May 2nd, 2007 04:34 PM
select statement help RinoDM SQL Server 2000 2 January 16th, 2007 11:35 AM
Select Statement jmss66 Oracle 1 May 27th, 2004 02:31 PM



All times are GMT -4. The time now is 09:13 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.