pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jeremy Dunn <jdunn@autorevenue.com>
To: matt@followers.net
To: Postgresql Performance <pgsql-performance@postgresql.org>
Subject: Re: Speeding up this function
Date: Tue, 19 Oct 2004 15:49:45 -0400
Message-ID: <008e01c4b614$c86aa550$4f01a8c0@jeremydunn> (raw)
In-Reply-To: <27c475ec04101912351c451e8@mail.gmail.com>

> -----Original Message-----
> From: pgsql-performance-owner@postgresql.org 
> [mailto:pgsql-performance-owner@postgresql.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




view thread (4+ messages)  latest in thread

Message-ID: <008e01c4b614$c86aa550$4f01a8c0@jeremydunn>
Permalink:  ../008e01c4b614$c86aa550$4f01a8c0@jeremydunn/
Also on:    postgresql.org/message-id/008e01c4b614$c86aa550$4f01a8c0@jeremydunn

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: jdunn@autorevenue.com, matt@followers.net
  Subject: Re: Speeding up this function
  In-Reply-To: <008e01c4b614$c86aa550$4f01a8c0@jeremydunn>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox