GeppoDarkson
Programmer
Hi to all,
I have a table containig 60 million of records containing 15 years of temperature data.
This table should be update every 15 minutes with records containing the temperature of the two last days (the new 15'+ the last 48 hours, in case of some data have changed by some external validation procedure).
The structures of BigTable and SmallTable are the same:
IdStation, DateAndHour, tValue.
What is the fastest way to perform this operation?
The following are too slow:
********************
Update BigTable B Set tValue=(Select tValue From SmallTable S Where B.IdStation= S.IdStation
And B.DateAndHour= S.DateAndHour)
Where Exist (Select tValue From SmallTable S1 Where B.IdStation= S1.IdStation
And B.DateAndHour= S1.DateAndHour)
(...And...)
Insert into BigTable
Select * From SmallTable S Where Not Exists(Select *
From BigTable B Where B.IdStation= S.IdStation
And BDateAndHour= S.DateAndHour)
********************
I've tried also this:
Update(Select B.tValue V1, S.tValue V2
From BigTable B Join SmallTable S On B.IdStation= S.IdStation
And BDateAndHour= S.DateAndHour)
Set V1=V2
Where V1<>V2
********************
...But performance are still slow.
Any suggestion?
Thank You.
Ciao,
GeppoDarkson.
I have a table containig 60 million of records containing 15 years of temperature data.
This table should be update every 15 minutes with records containing the temperature of the two last days (the new 15'+ the last 48 hours, in case of some data have changed by some external validation procedure).
The structures of BigTable and SmallTable are the same:
IdStation, DateAndHour, tValue.
What is the fastest way to perform this operation?
The following are too slow:
********************
Update BigTable B Set tValue=(Select tValue From SmallTable S Where B.IdStation= S.IdStation
And B.DateAndHour= S.DateAndHour)
Where Exist (Select tValue From SmallTable S1 Where B.IdStation= S1.IdStation
And B.DateAndHour= S1.DateAndHour)
(...And...)
Insert into BigTable
Select * From SmallTable S Where Not Exists(Select *
From BigTable B Where B.IdStation= S.IdStation
And BDateAndHour= S.DateAndHour)
********************
I've tried also this:
Update(Select B.tValue V1, S.tValue V2
From BigTable B Join SmallTable S On B.IdStation= S.IdStation
And BDateAndHour= S.DateAndHour)
Set V1=V2
Where V1<>V2
********************
...But performance are still slow.
Any suggestion?
Thank You.
Ciao,
GeppoDarkson.