Get metric ids from database.  Adds index.