473,387 Members | 1,619 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

problems running memory intensive queries

Hi,
i am having a strange problem running memory intensive queries on SQL
server.

I am doing an update on a table with 9 million records from another
table
with 50 records.

the query i am running is

update table1
set var1 = b.var2
from table2 b
where key1=b.key1

this query hanges for ever. I had thought that there was a problem with
my machine...but once out of the blue it ran in 16 minutes.

I am running a 1 Ghz PIII with 512 MB of memory.
Any ideas as to what could be the issue ?

Regards
Rishi

Jul 23 '05 #1
11 2079
forgot to mention...the size of the database is around 4 gb.
Cheers
Rishi

Jul 23 '05 #2
>From the limited info about your situation, I would say for starters
check to make sure you have proper indexes defined. Indexes are the key
to life in sql...

A good candidate for your indexes are the column in your where clause
and the column in your set clause....

-dave

Jul 23 '05 #3
(ri**********@yahoo.com) writes:
i am having a strange problem running memory intensive queries on SQL
server.

I am doing an update on a table with 9 million records from another
table with 50 records.

the query i am running is

update table1
set var1 = b.var2
from table2 b
where key1=b.key1

this query hanges for ever. I had thought that there was a problem with
my machine...but once out of the blue it ran in 16 minutes.


Does that UPDATE hit all nine million rows? In such case, it will
certainly take some time to execute the query. Things goes even worse
if the column you are updating is part of the clustered index. It gets
even worse if there is a trigger on the table.

For such huge updates, it's not an uncommon to run the update in batches.
In this case, maybe one update per key value could be an idea, at least
if there is an even distribution.

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #4
hi,
I also thought that the update would take too long and had given up
....but the funny thing is that once it ran in 16 mins and now when i
run it again, it hangs indefinitey...any clues ?

Jul 23 '05 #5
another point that i noted...the time when the query ran successfully
the task manager showed the cpu usage to be quite high and available
physical memory to be quite low...
but when it fails...the cpu usage is very low and the available memory
is also high ?

is that any kind of a sign ?

Rishi

Jul 23 '05 #6
i created an index on the key column and tried again....but alas no
result again..
it hanged.....
This is the cancellation message i get..

Query cancelled by User
[Microsoft][ODBC SQL Server Driver]Operation canceled
[Microsoft][ODBC SQL Server Driver]Timeout expired
ODBC: Msg 0, Level 16, State 1
Communication link failure

Rishi

Connection Broken

Jul 23 '05 #7
(ri**********@yahoo.com) writes:
I also thought that the update would take too long and had given up
...but the funny thing is that once it ran in 16 mins and now when i
run it again, it hangs indefinitey...any clues ?


Clues? With almost no knowledge about your tables?

Please post the CREATE TABLE and CREATE INDEX statements for your
tables, including FOREIGN KEY and CHECK constraints. Please also post
the exact UPDATE statement you are having problem with.

That is no guarantee that I or anyone will be able to say anything useful,
but at least it improves the odds.

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #8
hey the table create statement has 50 columns but i will list the most
important columns
there are no indexes on the table and no primary key

table name: DepTableFormat
rd_yr int,
vc_id int,
pc_nat_id int,
b_scno_vc int

the first 3 columns make up the structure of the table and account for
the 9 million rows.
then i take data from another table and join into the 4th column....

structure of the second table (BDataTable) is
rd_yr1 int,
b_scno_vc int

the query i run is

update DepTableFormat
set b_scno_vc = b.b_scno_vc
from BDataTable b
where rd_yr = b.rd_yr1

this will update all the 9 million records....

it takes forever,..... however i dont know how once it completed in 16
mins...
the transaction log has become bigger than my database also.
cheers
Rishi

Jul 23 '05 #9
hi,
I found the solution to my problem. I re phrased the sql query
and it worked
from :
update DepTableFormat
set b_scno_vc = b.b_scno_vc
from BDataTable b
where rd_yr = b.rd_yr1
to :
update DepTableFormat
set b_scno_vc = (select b.b_scno_vc
from BDataTable b
where rd_yr = b.rd_yr1)

and viola query runs in16 mins updating 9 million records
any light on the reasons ?

cheeros
Rishi

Jul 23 '05 #10
The answer is in the query plan (which we haven't seen)...

Note that the two queries are different. Query 1 will only update the
rows that have a matching row in table BDataTable. Query 2 will update
all rows in table DepTableFormat.

Gert-Jan
ri**********@yahoo.com wrote:

hi,
I found the solution to my problem. I re phrased the sql query
and it worked
from :
update DepTableFormat
set b_scno_vc = b.b_scno_vc
from BDataTable b
where rd_yr = b.rd_yr1
to :
update DepTableFormat
set b_scno_vc = (select b.b_scno_vc
from BDataTable b
where rd_yr = b.rd_yr1)

and viola query runs in16 mins updating 9 million records
any light on the reasons ?

cheeros
Rishi

Jul 23 '05 #11
(ri**********@yahoo.com) writes:
I found the solution to my problem. I re phrased the sql query
and it worked
from :
update DepTableFormat
set b_scno_vc = b.b_scno_vc
from BDataTable b
where rd_yr = b.rd_yr1
to :
update DepTableFormat
set b_scno_vc = (select b.b_scno_vc
from BDataTable b
where rd_yr = b.rd_yr1)

and viola query runs in16 mins updating 9 million records
any light on the reasons ?


No. You were asked to supply complete information about the tables, and
you didn't. That's your choice, but it is also my choice to refrain to
do guessworks on partial input.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Roy Smith | last post by:
I understand that psyco significantly increases memory use. Is that for code or data? More specifically, if I've got a memory intensive application (it might use 100's of Mbytes of data), should...
3
by: zeedan | last post by:
Hi, I appologise if I'm not posting this to the correct group, but I'm having problems starting MySQL server. I need it in order to post a websurvey for a research project I'm doing for a college...
7
by: Falnes | last post by:
We are developing applications in VB.Net which might be very CPU intensive. Our problem is that other applications running on the same machine is barely getting any processor resources at all. This...
6
by: George McLean | last post by:
Hello, I am trying to isolate some performance issues. The database is DB2 v8.1 running on a Win2000 server with 4 processors and 1gb of RAM. The application is a GIS application that uses...
1
by: Zeroeffect | last post by:
Hello! I have a database with alot of embedded images. The reason for having the images embedded is security. My problem is that it works fine on my computer, but not on my clients computer....
16
by: JCauble | last post by:
We have a large Asp.net application that is currently crashing our production servers. What we are seeing is the aspnet_wp eat up a bunch of memory and then stop unexpectedly. Does not recycle. ...
5
by: writeson | last post by:
Hi all, I'm wondering if anyone has tried a scenario that I'm thinking of. At my job we've got a web based product provided by Apache running PHP that accesses MySQL. This web application is...
2
by: Chris Ashley | last post by:
I have an ASP.Net page which does some very memory intensive GDI+ processing. This page is being called using AJAX by another script which I have no control over. What is happening is that the...
1
by: PowerLifter1450 | last post by:
I've been having a very rough time installinig mySQL on Linux. I have been following the instructions form here: http://www.hostlibrary.com/installing_apache_mysql_php_on_linux Everytime I get to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.