Scaleable DB structure for counters...

From: Eci Souji <eci(dot)souji(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Scaleable DB structure for counters...
Date: 2006-07-16 07:34:51
Message-ID: 44B9EC1B.3040008@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

So we've got a table called "books" and we want to build records of how
often each book is accessed and when. How would you store such
information so that it wouldn't become a huge unmanageable table?
Before I go out trying to plan something like this I figured I'd ask and
see if anyone had any experience with such a beast.

One idea I had was to create a separate DB for these counters and create
a schema for each year. Within each year schema I would create month
tables. Then I'd write a function to hit whatever schema existed like,
ala...

SELECT * FROM public.get_counters(date, hour, book_id);

get_day_counters would break up the date and based on the year do a
select counters from "2006".may WHERE day=12 and book_id=37. If hour
had a value it could do select counters from "2006".may where day=12 and
book_id=37 and hour=18.

Offline scripts would take care of generating and populating these
tables, as they'd be historical and never real-time.

Thoughts? I'm hoping someone has done something similar and can point
me in the right direction.

- E

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Harald Armin Massa 2006-07-16 07:51:57 Re: Scaleable DB structure for counters...
Previous Message Ed L. 2006-07-15 21:29:56 Log actual params for prepared queries: TO-DO item?