I have a big database with timestamps and sensor readings, which I
access with SELECT to have gnuplot draw graphs.  However, sometimes I
have readings every minute and want to plot several years of data, and
feeding everything to gnuplot is overkill.  In these cases it would be
sufficient to select only every nth row.  Is there a way to do this
efficiently (i.e. more efficient than just having gnuplot, which is
pretty fast, to plot everything)?

My rowid isn't increasing with something predictable, so I can't do
something like WHERE rowid % n = 0.  I can use WHERE random() % n = 0
giving me sort of what I want (better than row % n, but I still need
something better).

If your sampling is essentially regular, why not make it

select ... where timestamp % N between min_interval and max_interval

N being the typical time delta of your n rows above and interval bounds reducing the possiblity of gross under- and over-sampling. May need adjustment but the query should run faster than full table load.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to