title: What are some good ways to store performance statistics in a database for querying later?
body: <p><strong>Goal:</strong> Store arbitrary performance statistics of stuff that you care about (how many customers are currently logged on, how many widgets are being processed, etc.) in a database so that you can understand what how your servers are doing over time.</p>
  
  <p><strong>Assumptions:</strong> A database is already available, and you already know how to gather the information you want and are capable of putting it in the database however you like.</p>
  
  <p><strong>Some Ideal Attributes of a Solution</strong></p>
  
  <ul>
  <li>Causes no noticeable performance hit on the server being monitored</li>
  <li>Has a very high precision of measurement</li>
  <li>Does not store useless or redundant information</li>
  <li>Is easy to query (lends itself to gathering/displaying useful information)</li>
  <li>Lends itself to being graphed easily</li>
  <li>Is accurate</li>
  <li>Is elegant</li>
  </ul>
  
  <p><strong>Primary Questions</strong></p>
  
  <p>1) What is a good design/method/scheme for triggering the storing of statistics?</p>
  
  <p>2) What is a good database design for how to actually store the data?</p>
  
  <p><strong><em>Example answers...that are sort of vague and lame...</em></strong></p>
  
  <p>1) I could, once per [<em>fixed time interval</em>], store a row of data with all the performance measurements I care about in each column of one big flat table indexed by timestamp and/or server.</p>
  
  <p>2) I could have a daemon monitoring performance stuff I care about, and add a row whenever something changes (instead of at fixed time intervals) to a flat table as in #1.</p>
  
  <p>3) I could trigger either as in #2, but I could store information about each aspect of performance that I'm measuring in separate tables, opening up the possibility of adding tons of rows for often-changing items, and few rows for seldom-changing items.</p>
  
  <p>Etc.</p>
  
  <blockquote>
    <blockquote>
      <p>In the end, I will implement <em>something</em>, even if it's some super-braindead approach I make up myself, but I'm betting there are some really smart people out there willing to share their experiences and bright ideas!</p>
    </blockquote>
  </blockquote>