-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP Generating primary key for raw_data #145
Comments
Hm, do you know where this is defined? CREATE INDEX sensor_sensor_7a592b3b
ON public.sensor_sensor
USING btree
(sensor_type_id); In any case, we might have to delete any |
This PR is only step 1? That is the way it should be in my opinion.
19. feb. 2017 23:22 skrev "Pål Grønås Drange" <notifications@github.com>:
… Hm, do you know where this is defined?
CREATE INDEX sensor_sensor_7a592b3b
ON public.sensor_sensor
USING btree
(sensor_type_id);
In any case, we might have to delete any INDEX before performing step 2:
moving primary key from sensor_id to s_id (integer key).
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#145 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABQqwY9Z7-_OVAMIsb-c8xet9v-hK-htks5reMCugaJpZM4MFnRB>
.
|
This is only step 1, yes. I'm still struggling with
|
Hehe - this stuff is beyond my SQL pay-grade 😄 |
I've done it now locally. I had to delete the filter*-tables, and I also deleted time_series* and plot-* tables. |
def forwards(apps, schema_editor):
import sys
if not schema_editor.connection.alias == 'default':
return
sensor = apps.get_model('sensor', 'Sensor')
rawdata = apps.get_model('sensor', 'RawData')
sensors = {}
for row in sensor.objects.all():
sensor_name = row.sensor_id
sensor_id = row.s_id
sensors[sensor_name] = row
for row in rawdata.objects.all():
sensor_name = row.sensor_id
if sensor_name not in sensors:
sys.stderr.write('\nNo sensor for key "%s".\n' % sensor_name)
row.s_id = None
else:
row.s_id = sensors[sensor_name]
row.save() With class RawData(Model):
sensor_id = CharField(max_length=128)
s_id = ForeignKey( Sensor, null = True )
timestamp_recieved = DateTimeField( )
timestamp_data = DateTimeField( )
value = FloatField( default = -1 )
processed = BooleanField( default = False ) |
We need to create dummy sensors for
But other than that, we're ready to go! @joakim-hove Is it okay if we delete the filter-tables in the heroku db? |
Delete delete! When it comes to dummy sensors we might go the delete route instead? |
Definitely. What's the gas sensor? Almost 500k rows? |
The we can go back to, for each sensor, def get_data_list(sensor, start, end):
data_all = RawData.objects.filter(s_id=sensor.s_id,
timestamp_data__range=
(start,end)).values("value",
"timestamp_data"
).order_by('timestamp_data')
datalist = downsample(list(data_all), minutes=30, cutoff=100)
datalist = map( make_timestamp , datalist )
return datalist And we're more or less done with the migration. :) |
Have performed the following steps upstream:
The latter step is currently under testing at my machine. If successes galore, I will |
In fact, after indexing on
When we started way back in the beginning (before quick), we were at several seconds for SQL. Now we're down to less than 0.2s! |
WIP for the first step, adding an integerfield primary key to
sensor_sensor
:Two steps:
Model file:
Migration file:
The text was updated successfully, but these errors were encountered: