Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Microsoft SQL Server > Performance que...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 3 Topic 10993 of 11265
Post > Topic >>

Performance question concerning varchar(max)

by "Bill E." <billmiami2@[EMAIL PROTECTED] > Apr 23, 2008 at 07:17 AM

SQL Server 2005
Simple scenario - We want to store answers to survey questions.  Some
questions require very short responses (one or two words) while others
require long essay type responses.

--Scenario 1 -- store all answers in one column, regardless of
question
CREATE TABLE Answers
(
	AnswerID int identity PRIMARY KEY,
	UserID int,
	QuestionID int,
	AnswerText varchar(max)
)

--Scenario 2 -- store answers to short questions in one column and
long ones in another
CREATE TABLE Answers
(
	AnswerID int identity PRIMARY KEY,
	UserID int,
	QuestionID int,
	ShortAnswerText varchar(50),
	LongAnswerText varchar(max)
)

Assume an index on QuestionID

If we need to query the table as in Scenario 1 for short question 27
as in

SELECT UserID, AnswerText
FROM Answers
WHERE QuestionID = 27 And AnswerText Like '%headache%'

Will we suffer a performance penalty vs. querying Scenario 2 as in

SELECT UserID, ShortAnswerText
FROM Answers
WHERE QuestionID = 27 And ShortAnswerText Like '%headache%'

I would think that the optimizer would first use the index on
QuestionID and this would eliminate the "baggage" of having to sort
through the responses to long questions in the AnswerText column but
perhaps this isn't the case.

Bill E.
Hollywood, FL
 




 3 Posts in Topic:
Performance question concerning varchar(max)
"Bill E." <b  2008-04-23 07:17:30 
Re: Performance question concerning varchar(max)
Hugo Kornelis <hugo@[E  2008-04-23 20:44:13 
Re: Performance question concerning varchar(max)
"Bill E." <b  2008-04-25 07:57:21 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan13V112 Fri Jul 25 5:29:35 CDT 2008.