Change query for anfor_trajectory_wms table for better performance