I have also started to see MySQL slow query log entries lately; I can't say if it started with NextGEN Gallery version 2.0.40. The site has about 800 images in 40 galleries. Here's a sample:
# Query_time: 14 Lock_time: 0 Rows_sent: 173 Rows_examined: 4431348
use s******;
SELECT galleryid, COUNT(*) as counter , wp_options
.option_value
AS 'custom_post_id', GROUP_CONCAT(CONCAT_WS('@@', meta_key, meta_value)) AS 'extras' FROM wp_ngg_pictures
LEFT OUTER JOIN wp_options
ON wp_options
.option_name = CONCAT('wp_ngg_pictures_', wp_ngg_pictures.pid) LEFT OUTER JOIN wp_postmeta
ON wp_postmeta
.post_id
= wp_options
.option_value
WHERE (galleryid
IN (35, 38, 15, 16, 41, 17, 14, 43)) GROUP BY galleryid, wp_ngg_pictures.pid;