The where clause for the apm_packages looks very "unselective" so it seems understandable that the query optimizer is opting for a table scan.