Get terms of the posts with one query

You can use the following SQL query

SELECT * FROM wp_posts a, wp_term_relationships b, wp_terms c WHERE a.post_status="published" AND a.ID = b.object_id AND b.term_id = c.term_id;

This will list all the post that is in the published state and then its terms.

You can add limits and offsets to limit the number of records.