Re: Speeding up this function

From: "Jeremy Dunn" <jdunn(at)autorevenue(dot)com>
To: <matt(at)followers(dot)net>, "Postgresql Performance" <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Speeding up this function
Date: 2004-10-19 19:49:45
Message-ID: 008e01c4b614$c86aa550$4f01a8c0@jeremydunn
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

> -----Original Message-----
> From: pgsql-performance-owner(at)postgresql(dot)org
> [mailto:pgsql-performance-owner(at)postgresql(dot)org] On Behalf Of
> Matt Nuzum
> Sent: Tuesday, October 19, 2004 3:35 PM
> To: pgsql-performance
> Subject: [PERFORM] Speeding up this function
>
<snip>
>
> All it does is try to "link" pageviews together into a session.
> here's the function:
> create or replace function usage_normalize_session
> (varchar(12), inet, timestamptz) returns integer as ' DECLARE
> -- $1 = Account ID, $2 = IP Address, $3 = Time
> RecordSet record;
> BEGIN
> SELECT INTO RecordSet DISTINCT sessionid FROM usage_access ua
> WHERE ua.accountid = $1
> AND ua.client = $2
> AND ua.atime <= ($3 - ''20
> min''::interval)::timestamptz;
>
> if found
> then return RecordSet.sessionid;
> end if;
>
> return nextval(''usage_session_ids'');
> END;'
> language plpgsql;
>

This is probably a stupid question, but why are you trying to create
sessions after the fact? Since it appears that users of your site must
login, why not just assign a sessionID to them at login time, and keep
it in the URL for the duration of the session? Then it would be easy to
track where they've been.

- Jeremy

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Matt Nuzum 2004-10-19 19:55:04 Re: Speeding up this function
Previous Message Matt Nuzum 2004-10-19 19:35:24 Speeding up this function