From afdde4cd46e93bd49588a47029736c92d0c31ae0 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Sun, 30 Jul 2006 14:50:19 +0200 Subject: [PATCH] Avoid a rescan of all images every time we upload something. --- perl/Sesse/pr0n/Common.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/perl/Sesse/pr0n/Common.pm b/perl/Sesse/pr0n/Common.pm index 76da6be..ecc039e 100644 --- a/perl/Sesse/pr0n/Common.pm +++ b/perl/Sesse/pr0n/Common.pm @@ -192,8 +192,8 @@ sub update_width_height { # update the last_picture cache as well (this should of course be done # via a trigger, but this is less complicated :-) ) - $dbh->do('UPDATE events SET last_picture=(SELECT COALESCE(MAX(date),\'1970-01-01 00:00:00\') FROM images WHERE event=events.id) WHERE id=(SELECT event FROM images WHERE id=?)', - undef, $id) + $dbh->do('UPDATE events SET last_picture=GREATEST(last_picture, ?) FROM images WHERE event=events.id) WHERE id=(SELECT event FROM images WHERE id=?)', + undef, $datetime, $id) or die "Couldn't update last_picture in SQL: $!"; } -- 2.39.2