| Author |
Topic |
|
jmcbride
Starting Member
24 Posts |
Posted - 2003-09-05 : 15:55:59
|
I have a column which has a URL that I need to replace. I have been trying to use this article http://www.sqlteam.com/item.asp?ItemID=7386 as a guide but this query seems to take forever and cause our server to hang.The column that I am working on was an ntext column with 16 characters. I converted it to a varchar with 500 just in case.Why are these queries taking so long?Update event Set description = replace(description, 'dpweb1.dp', 'utdirect') --------------------http://www.mejoe.com/(Joe) Joseph McBride |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2003-09-05 : 16:01:57
|
| What indexes do you have on the Event table?Tara |
 |
|
|
setbasedisthetruepath
Used SQL Salesman
992 Posts |
Posted - 2003-09-05 : 16:03:43
|
| And how many rows in the event table, and how many bytes wide is the event table? What is the estimated cost of the update?Jonathan{0} |
 |
|
|
jmcbride
Starting Member
24 Posts |
Posted - 2003-09-05 : 16:49:39
|
- There are no indexes on the Event table.
- There are about 1500 rows
- I am not sure how many bytes wide the table is but I added together the length of each column and got 964.
- By cost do you mean how many rows contain the text to be updated? I count 711 rows.
--------------------http://www.mejoe.com/(Joe) Joseph McBride |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2003-09-05 : 17:06:30
|
Joe,That's pretty much a drop of water in an ocean....Is anyone else using and locking the table?Is tempdb hosed?REPLACE I guess is kind of a pig...but the following below takes about 19 seconds..Total of about 2,000 rows, and 4k bytes per row of data to change.USE NorthwindGODECLARE @x int,@start datetime, @end datetime SELECT @x=0, @start = Getdate()SET NOCOUNT ONSELECT * INTO myTable99 FROM ( SELECT *, REPLICATE('X',4000) AS colx FROM [order details] ) AS xxxSELECT COUNT(*) FROM myTable99UPDATE myTable99 SET colx=REPLACE(colx,'X','A')SELECT 'Time Elapsed (ss): '+ Convert(varchar(25),DATEDIFF(ss,@start,getdate()))GODROP TABLE myTable99GOSee how lomg it takes you when you cut and paste it in to QA..Brett8-)SELECT @@POST=NewId()That's correct! It's an AlphaNumeric! |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2003-09-05 : 17:19:44
|
Joe, are you sure that the UPDATE statement is what is causing the server to hang? My code below only takes one second to run:SET NOCOUNT ONCREATE TABLE event(Column1 INT NOT NULL,description VARCHAR(500) NOT NULL)DECLARE @int INTSET @int = 1WHILE @int <= 1500BEGIN INSERT INTO event VALUES(@int, CONVERT(VARCHAR(5), @int) + REPLICATE('X', 50) + 'dpweb1.dp' + CONVERT(VARCHAR(5), @int) + REPLICATE('Z', 5)) SET @int = @int + 1ENDSELECT Column1, descriptionFROM eventUPDATE event SET description = REPLACE(description, 'dpweb1.dp', 'utdirect')SELECT Column1, descriptionFROM eventDROP TABLE eventI create the table, insert 1500 rows, get the 1500 rows, update the 1500 rows, get the updated 1500 rows, then drop the table. All of this happens in just one second. I suspect something else is causing your problem. Run SQL Profiler to determine what the cause is.Tara |
 |
|
|
jmcbride
Starting Member
24 Posts |
Posted - 2003-09-05 : 17:38:00
|
| Thanks for the help, I temporarily disabled access by users and the query ran in under a second! Sorry about the trouble.--------------------http://www.mejoe.com/(Joe) Joseph McBride |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2003-09-05 : 22:36:43
|
quote: Originally posted by jmcbride Thanks for the help, I temporarily disabled access by users and the query ran in under a second! Sorry about the trouble.--------------------http://www.mejoe.com/(Joe) Joseph McBride
Yo dude...don't be sorry...otherwiswe we'd have nothing to do...well, there is work, but I find helping more satifying...at least thats what I try to do.,,,,this hp keyboard sucks...or maybe it's 6he cocktails...Brett8-)SELECT @@POST=NewId()That's correct! It's an AlphaNumeric! |
 |
|
|
|