title: What Database / Technology should be used to calculate unique visitors in time scope
body: <p>I've got a problem with performance of my reporting database (tables have millions of records, 50+), when I want to calculate distinct on column that indicates a visitor uniqueness, let's say some hashkey. </p>
  
  <p>For example:
  I have these columns:
  hashkey, name, surname, visit_datetime, site, gender, etc...</p>
  
  <p>I need to get distinct in time span of 1 year, less than in 5 sec:</p>
  
  <pre><code>SELECT COUNT(DISTINCT hashkey) FROM table WHERE visit_datetime BETWEEN 'YYYY-MM-DD' AND 'YYYY-MM-DD' 
  </code></pre>
  
  <p>This query will be fast for short time ranges, but if it be bigger than one month, than it can takes more than 30s.</p>
  
  <p>Is there a better technology to calculate something like this than relational databases? </p>
  
  <p>I'm wondering what google analytics use to do theirs unique visitors calculating on the fly.</p>