improve query to get the attributes of the database