Results 1 to 2 of 2

Thread: STEP like function?

  1. #1
    Join Date
    Feb 2003
    Location
    Johannesburg, South Africa
    Posts
    145

    Question STEP like function?

    Hi

    Short Problem Description:

    I want to get totals of a field at certain time intervals ( say, every 5 seconds ).

    Longer Problem Description:

    Imagine a table with two columns: timestamp and value ( int )

    Now, I want to start at a certain time, get the total value for the start time plus 5 seconds; then move on 5 seconds and get the next 5 seconds total etc. until I have all the intervals with their totals.

    Is there a short way?

    I currently do this programitaclly with Perl and some weird hash tricks.

    I wonder if there is a function that can do this in MySQL, and if yes, will it be faster to execute then on a perl script?

    I use MySQL 3.23.47

    Thanks

  2. #2
    Join Date
    Feb 2003
    Location
    Johannesburg, South Africa
    Posts
    145

    Lightbulb Workaround

    For those interested, I have decided on the following workaround for the problem:

    First of all, I knew that I would always want the data within a set interval, so I modified the table structure a bit and the script that now populates the database, populate in 5 seconds summaries, which means a normal select statement shows the 5 second interval results.

    The only down side is that you loose the original data for custom queries based on the original dataset. The workaround for this is to have two tables: one holding the original data, and one holding the summarised data ( which is roughly 5 times smaller then the original data ).

    Any other ideas will still be welcome

    Cheers

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •