krisbrixon
Programmer
Which do you think would be faster.
Base information:
- Three tables
Table 1 has @ 100 records (i.e. Batch File)
Table 2 has @ 5000 records (i.e. Active File)
Table 3 has > 1,000,000 records (i.e. Historical File)
- The value I want will be in only one of the three tables.
- There is an 80% chance that it will be in table 2.
- There is a 1% chance that it will be in table 1.
- All three table have very similar structure.
- Using an Scalar recordset with VB.NET returning a SUM()
- SUM function will sum @ 1-20 records.
- A Stored Procedure is not a vaild option.
Option 1
- Join all three tables together and get the answer.
Option 2
- Run a statement on each of the tables and look at the results to see which one had the answer. In VB.NET setup a nested IF statment that will check each answer before if runs the next query and will stop running the queries if it finds one.
i.e.
If NOT "Run SQL on Table 2" > 0 Then
If NOT "Run SQL on Table 3" > 0 Then
If NOT "Run SQL on Table 1" > 0 Then
Return "value"
End If
Else
Return "value"
End If
Else
Return "value"
End If
Even if you do not know for sure, I would appreciate any semi-confident guesses.
Thanks,
Kris
Base information:
- Three tables
Table 1 has @ 100 records (i.e. Batch File)
Table 2 has @ 5000 records (i.e. Active File)
Table 3 has > 1,000,000 records (i.e. Historical File)
- The value I want will be in only one of the three tables.
- There is an 80% chance that it will be in table 2.
- There is a 1% chance that it will be in table 1.
- All three table have very similar structure.
- Using an Scalar recordset with VB.NET returning a SUM()
- SUM function will sum @ 1-20 records.
- A Stored Procedure is not a vaild option.
Option 1
- Join all three tables together and get the answer.
Option 2
- Run a statement on each of the tables and look at the results to see which one had the answer. In VB.NET setup a nested IF statment that will check each answer before if runs the next query and will stop running the queries if it finds one.
i.e.
If NOT "Run SQL on Table 2" > 0 Then
If NOT "Run SQL on Table 3" > 0 Then
If NOT "Run SQL on Table 1" > 0 Then
Return "value"
End If
Else
Return "value"
End If
Else
Return "value"
End If
Even if you do not know for sure, I would appreciate any semi-confident guesses.
Thanks,
Kris