optimize media tags query for media.csv