Ok, i understood that Core.retrieveIds does not use caching, so in general the first solution will be at least as fast as the second one. I guess in most cases it is even faster, since it saves at least one database query.
The OrderObject.getMember("Orders.Orderlines").getValue() approach however seems to be faster than the query approach, if you only need the IMendixIdentifiers, and not the objects themselves (for example to amend a referenceset).