If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > SQL Help

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-25-05, 10:06
rhayabusa rhayabusa is offline
Registered User
 
Join Date: Feb 2005
Posts: 21
SQL Help

Is there anyway to make this query more efficient. I've been told that it uses to much memory. Thanks


With
Stage1 As(Select acc_no, sum(column1) as s1, sum(column2) as s2,
sum(column3) as s3,...
From Table1
Where Date = '??/??/????'
Group by acc_no),

Stage2 As(Select * From Stage1
Where s1 > 0 or s2 > 0 or s3 > 0 ...)

Select count(*) from Stage2;
Reply With Quote
  #2 (permalink)  
Old 02-25-05, 11:42
przytula przytula is offline
Registered User
 
Join Date: Nov 2004
Posts: 374
memory

if this query or similar queries are often executed, maybe ast automated summary tables would help
Have a look in reference how to handle these
Best Regards, Guy Przytula
__________________
Best Regards, Guy Przytula
DB2/ORA/SQL Services
DB2 DBA & Advanced DBA Certified
DB2 Dprop Certified
http://users.skynet.be/przytula/dbss.html
Reply With Quote
  #3 (permalink)  
Old 02-25-05, 12:58
rhayabusa rhayabusa is offline
Registered User
 
Join Date: Feb 2005
Posts: 21
Thanks, I'll have a look. What happens is that everytime I run that query the database goes down.
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 On
Pingbacks are On
Refbacks are On