Aggregation pipeline like that would be better, with a nicer code and sooooo muuuuuch faasssster
db.pim_catalog_product.aggregate(
    { $match: { enabled: true} },
    { $project: { "values.attribute": 1} },                                                                          
    { $unwind: "$values" },
    { $group: {
        _id : "$values.attribute"
        }
    }
);