Re: Correct/optimal DML query for application session management ?

From: Alban Hertroys <haramrae(at)gmail(dot)com>
To: Tim Smith <randomdev4+postgres(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Correct/optimal DML query for application session management ?
Date: 2015-01-06 20:15:25
Message-ID: 7DD40C2A-1698-4C3F-BA26-49974C468AEE@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


> On 06 Jan 2015, at 19:02, Tim Smith <randomdev4+postgres(at)gmail(dot)com> wrote:
> create table app_sessions(
> session_id char(64) unique not null,
> user_id char(32) unique not null,
> session_start bigint not null,
> session_lastactive bigint not null
> );

Just an observation: Are you sure that you don’t want to allow your users to have multiple sessions? You made users unique across the entire table, which mean there can only ever be one session for a user. Unless you delete ‘expired’ sessions ASAP, users won’t be able to start a new session again after their original session expired.
That may be desirable for your application and thus intended, but perhaps it was not?

Alban Hertroys
--
If you can't see the forest for the trees,
cut the trees and you'll find there is no forest.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Michael Heaney 2015-01-06 21:18:29 Re: Advice for using integer arrays?
Previous Message Andy Colson 2015-01-06 20:10:31 Re: Correct/optimal DML query for application session management ?