> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] 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


---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

Reply via email to