Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>most efficient (query performance and memory consumption)</p> </blockquote> <p>By this you probably mean something that is well balanced between the two. Also, I think that the data insertion must be fast.</p> <p>The easiest and maybe sufficient solution would be to use plain array IMO as it is most memory efficient non-compressed form you can store the data. Thus each array element contains the <code>timestamp, id and value</code>.</p> <p>When you query the data with two timestamps <code>begin</code> and <code>end</code>, you determine the locations of the timestamps in the array using <code>binary search</code>. Then, you traverse all the elements and fetch only the ones with id-s of data sources you are interested in. The array elements must be of course ordered by timestamps.</p> <ul> <li>The data takes O(n) memory, where the number of log entries is n.</li> <li>Data insertion is O(1)</li> <li>Data retrieval should be something like O(2*log(n) + n*m), where n is the number of elements. If you have more data sources you want to include in the query, then you can store the data source ID-s in a set, thus the complexity would be O(2*log(n) + n*log(m)). </li> </ul> <p>There are of course other possibilities that can involve storing the transactions in trees, hashtables or something that mixes these with lists to get more detailed balance between performance/memory consumption.</p> <p>Also, the problems arise, when the amount of logs is large. In that case, you should split the array into files and store the begin/end timestamps the files contain the logs. Then the implementation gets a little bit more complex.</p> <p>Hopefully this helps somehow you to decide the best data structure / implementation for your solution.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload