|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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? |
|
#2
|
|||
|
|||
|
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 |
|
#3
|
|||
|
|||
|
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.
|
|
#4
|
|||
|
|||
|
oops
Sorry, forgot I posted in Access/SQL Server forum too. See details there.
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > Programming Tools > Problem with SQL join performance... |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|