2 CREATE or REPLACE FUNCTION get_last_played( TEXT ) RETURNS TIMESTAMP AS '
7 -- ORDER BY hash_key and req_at makes index choice more sane.
8 SELECT req_at INTO last_time FROM played WHERE hash_key=hash
9 ORDER BY hash_key DESC, req_at DESC LIMIT 1;
11 last_time := ''-infinity'';
15 ' LANGUAGE 'plpgsql' STRICT;