Before:
mysql> explain SELECT galleryid, COUNT(*) as counter , `options`.`option_value` AS 'custom_post_id', GROUP_CONCAT(CONCAT_WS('@@', meta_key, meta_value)) AS 'extras' FROM `ngg_pictures` LEFT OUTER JOIN `options` ON `options`.option_name = CONCAT('ngg_pictures_', ngg_pictures.pid) LEFT OUTER JOIN `postmeta` ON `postmeta`.`post_id` = `options`.`option_value` WHERE (`galleryid` IN (1746, 1747, 1749, 1748, 1750, 1751, 1752, 1753, 1745, 1754)) GROUP BY galleryid, ngg_pictures.pid;
+----+-------------+--------------+------+---------------+---------+---------+----------------------------+-------+----------------------------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+--------------+------+---------------+---------+---------+----------------------------+-------+----------------------------------------------+
| 1 | SIMPLE | ngg_pictures | ALL |