Programming Tools
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingProgramming Tools

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old January 8th, 2003, 09:40 PM
csuttman csuttman is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Posts: 5 csuttman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Problem with SQL join performance...

I am doing a basic SQL statement that reads from 1 file and has a simple where statement as such...

select *
from table1
where date1 = '1/8/2003'

Table1 has over 8 million records and an index on the field in the where statement (date1). This works lightning fast. Problem is when I join another file that currently has only one record in it as such...

select *
from table1, table2
where date1 = date2

Seems simple enough, and with only one record in table2... I didn't think performance would be effected too much. WRONG! The statement went from sub-second results to taking over 4 minutes. I am doing the join because table2 may have multiple records. Anybody have a clue how to beat this problem?

Reply With Quote
  #2  
Old January 10th, 2003, 02:25 AM
kkfu kkfu is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Posts: 1 kkfu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Use:

select [table1].[FieldName1], [table1].[FieldName2],...
from [table1] left join [table2]
where [table1].[date1] = [table2].[date2]

Clues:
Avoid use "*": the engine need search first all the fields in each table, so if table1 has 15 fields and table2 has 30 fields, the DB engine need calculate all taht information.

Use "Joins": "left join", "inner join", "right join", I don't know the struct of your DB but I suppose you have a relationed field in each table, so you can always improve your queries using clausules join.

I hope this help you. Regards

Reply With Quote
  #3  
Old January 11th, 2003, 01:34 PM
csuttman csuttman is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Posts: 5 csuttman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
working now, but looking for explanation or workaround

I got it working now, but now I'm looking for explanation or workaround. Please see my response to the previous person's suggestion for details.

Reply With Quote
  #4  
Old January 11th, 2003, 01:37 PM
csuttman csuttman is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Posts: 5 csuttman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
oops

Sorry, forgot I posted in Access/SQL Server forum too. See details there.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingProgramming Tools > Problem with SQL join performance...


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 On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | 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 4 hosted by Hostway