automatically run query in server