On Nov 29, 2011, at 3:51 AM, Tate Kim wrote:
> Hello everyone,
>
> I think this question may be for the database side, but i 'd like to post
> here if you don't mind.
>
>
> I have a certain periodic task that bult updates a couple of columns has
> expired in "License" table. ( It doesn't matter what it is. )
>
> In this situation, time accuracy was really important to me so i was running
> the task per one minute.
>
> The code is like this.
>
> # call in every one minute with something like MQ
> session.query( License ).filter( License.expired_at > func.now() ).update({
> License.type: 'basic'
> })
>
> But, if I want to modify this period down to 1 sec, as you know performance
> is gonna be really bad.
I don't think you mean "performance" you mean "accuracy". It depends on
what "clock" you're synchronizing here on - if you can emit the statements
every second from the app side, you could possibly use timestamps from the app
end. If the app and database clocks aren't perfectly synchronized, maybe the
app could just subtract app time - DB time and add that in as a fudge factor.
But yeah I haven't ever had to get sub-second accuracy on something like this
so I don't know if that really works.
>
> If License.expired_at were not datetime field, i would try with sqlalchemy's
> event api at the orm attribute's changing point...
I'm not really understanding how the datatype of "expired_at" has any bearing
on a particular Python calling style.
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.