Databases
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   Web Development Archives FAQs Databases

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Web Development Archives Sponsor:
  #1  
Old June 3rd, 2008, 09:30 PM
Jorge Reyes
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Another big delay

Hi again, this is something that i can't understand yet, i mean do
querys thinking in whole sets and not just row by row, look i have to
do this

Table A = 88,400 rows, 3 columns (id,date,minid)
Table B = 7,7887 rows, 2 columns (corpo_id, minid)

the goal is ¿how many distincts minid's are in the table A group by
corpo_id? i mean this for example:

Table A
1, 2008-06-03 00:00:00, 123456789
2, 2008-06-03 00:00:00, 333333333
3, 2008-06-03 00:00:00, 123456789
4, 2008-06-03 00:00:00, 123456789
5, 2008-06-03 00:00:00, 999999999
6, 2008-06-03 00:00:00, 999999999
7, 2008-06-03 00:00:00, 999999999
8, 2008-06-03 00:00:00, 999999999
9, 2008-06-03 00:00:00, 123456789
10, 2008-06-03 00:00:00, 123456789

Table B
baz, 123456789
baz, 333333333
ekt, 999999999

then the result for baz must be: 2
and for ekt: 1

so i did this:

SELECT ****(DISTINCT(A.MINid)) AS 'TTAL_BAZ'
FRM TABLE_A AS A
JIN TABLE_B AS B N A.MINid = B.MIN_id
WHERE B.corpo_id = 'BAZ'

SELECT ****(DISTINCT(A.MINid)) AS 'TTAL_BAZ'
FRM TABLE_A AS A
JIN TABLE_B AS B N A.MINid = B.MIN_id
WHERE B.corpo_id = 'EKT'

my problem is the time of response, this takes more than 23 minutes,
¿how can i do this faster?

Please help this is really urgent, thanks in advanced.


Reply With Quote
  #2  
Old June 5th, 2008, 05:30 PM
Sybaseguru
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Another big delay

I may not understand your problem properly, but I've always found it best to
use temp tables when the problem is complex and reduce the data sets along
the lines of

#
# firstly get a list of minid's in Table A
#
select distinct(minid) into #a from TableA
#
# next match them to Table B and count them.
#
select corp_id,count(b.minid)
from #a a,TableB b
where a.minid=b.minid

this should have a sub-second run time.


Jorge Reyes wrote:

Hi again, this is something that i can't understand yet, i mean do
querys thinking in whole sets and not just row by row, look i have to
do this
>

Table A = 88,400 rows, 3 columns (id,date,minid)
Table B = 7,7887 rows, 2 columns (corpo_id, minid)
>

the goal is ¿how many distincts minid's are in the table A group by
corpo_id? i mean this for example:
>

Table A
1, 2008-06-03 00:00:00, 123456789
2, 2008-06-03 00:00:00, 333333333
3, 2008-06-03 00:00:00, 123456789
4, 2008-06-03 00:00:00, 123456789
5, 2008-06-03 00:00:00, 999999999
6, 2008-06-03 00:00:00, 999999999
7, 2008-06-03 00:00:00, 999999999
8, 2008-06-03 00:00:00, 999999999
9, 2008-06-03 00:00:00, 123456789
10, 2008-06-03 00:00:00, 123456789
>

Table B
baz, 123456789
baz, 333333333
ekt, 999999999
>

then the result for baz must be: 2
and for ekt: 1
>

so i did this:
>

SELECT ****(DISTINCT(A.MINid)) AS 'TTAL_BAZ'
FRM TABLE_A AS A
JIN TABLE_B AS B N A.MINid = B.MIN_id
WHERE B.corpo_id = 'BAZ'
>

SELECT ****(DISTINCT(A.MINid)) AS 'TTAL_BAZ'
FRM TABLE_A AS A
JIN TABLE_B AS B N A.MINid = B.MIN_id
WHERE B.corpo_id = 'EKT'
>

my problem is the time of response, this takes more than 23 minutes,
¿how can i do this faster?
>

Please help this is really urgent, thanks in advanced.


Reply With Quote
Reply

Viewing: Web Development Archives FAQs Databases > Another big delay


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT