[vz-users] SQL Abfrage Zählerstände Tagesende ?

Jakob Hirsch jh at plonk.de
Mon Feb 25 10:06:26 CET 2013


Thomas Janz, 24.02.2013 18:56:
> Ich habe die Abfrage noch etwas eingegrenzt 23:59:5%' hast du eine Idee
> warum die Warnung kommt ?
> 
> 171 rows in set, 1 warning (3 min 13.25 sec)

Ohje. Etwas umständlicher, dafür korrekt und performant:

m=1; for d in $(seq 1 31); do for ch in 19 20 21; do echo "select
date(from_unixtime(timestamp/1000)), channel_id, value from data where
channel_id=$ch and timestamp>=unix_timestamp('2013-$m-$d')*1000 and
timestamp<unix_timestamp(date_add('2013-$m-$d', interval 1 day))*1000
order by timestamp desc limit 1;"; done; done | mysql -NB volkszaehler

Das braucht bei mir gerade mal 70ms.

Kann man mit Sicherheit auch direkt in mysql machen, dafür fehlt mir
aber gerade Zeit und Muse :)



More information about the volkszaehler-users mailing list