Sql optimizations on /period/

Prefetch the previous period for each player. Greatly decreases the number of queries.
Merge pull request #115 from Prillan/sql-optimizations

Sql optimizations on /period/