Added optimization for update_epg event (issue #2933)
Added index to the last_id table (issue #2941)