On Fri, Jul 10, 2009 at 2:02 AM, Alvaro Herrera
<alvhe...@commandprompt.com>wrote:

> What do the INSERT lines look like?  Is it a trigger, an insert called
> directly by the application?  How is the sequence involved -- lastval(),
> nextval(), does the code just leave the column out for the default to fire?
>
>

* This is the INSERT query, called from PHP/Apache

INSERT INTO log_event (user_id, ip, action_id, object1_id, object2_id,
event_timestamp)
VALUES ($1, $2, $3, $4, $5, NOW())

So the timestamp is generated by NOW(), and the pkey is generated by using
the default value (nextval).

* There are no UPDATE queries.

* There a few DELETE queries that are lauched daily (called from PHP/cron)

DELETE FROM log_event WHERE action_id = $1 AND event_timestamp < NOW() - '1
month'::interval

(some events are not worthy of archiving individually, we just keep totals)


Regards,
Mathieu

Reply via email to