Subject Re: Update take hours to delete records :(
Author nathanelrick
> i am curious why do you use also date - not only id in this statement?
> id is not primary key?

yes id is the primary key (the session ID), but when i retrieve a session, i want only session that are not yet expired (if not session ID is not to be used anymore and new session ID must be recreated)


> > Update Session Set
> > data=...
> > Expiry_date= NOW + 15minutes
> > where
> > id=... and
> > Date_expired < 'NOW'
>
>
> and more relevant question
> how offen do you fire update of session in every request?
> if in every request then this is not good solution.

yes in every request i fire update :( because in every request i update the expiry_date to be now + 15 minutes ...


> if you need to control session in e.g. 15 minutes live then
> you can optimise record versions count like this
>
> Update Session Set
> data=...
> Expiry_date= NOW + 15minutes
> where
> id=... and
> Date_expired > DATEADD(-5 minute to CAST('now' AS TIMESTAMP))
>
> in this scenario you generate record version in every 5 minutes not in every request

yes ! that can be most better you are right ! i will also do like this


> also look at external tables - if you need update in every request - this is better for you (no record versions)
> But i do not know how many active sessions are in the same time (external tables do not use indexes)

no if external table not use index it's will worse, i thing in a gap of 15min we can have thousands users :( but you idea to limit the amout of update is not bad i will try it ! just sad i didn't see it by myself !