docs: public static <O> DistanceQuery<O> precomputedDistanceQuery(Database database, Relation<O> relation, DistanceFunction<? super O> distf, Logging log) {
      DistanceQuery<O> dq = database.getDistanceQuery(relation, distf, DatabaseQuery.HINT_HEAVY_USE, DatabaseQuery.HINT_OPTIMIZED_ONLY);
      if(dq == null) {
        DBIDs ids = relation.getDBIDs();
        if(ids instanceof DBIDRange) {
          log.verbose("Precomputing a distance matrix for acceleration.");
          PrecomputedDistanceMatrix<O> idx = new PrecomputedDistanceMatrix<O>(relation, (DBIDRange) ids, distf);
          idx.initialize();
          // TODO: attach weakly persistent to the relation?
          dq = idx.getDistanceQuery(distf);
        }
      }
      if(dq == null) {
        dq = database.getDistanceQuery(relation, distf, DatabaseQuery.HINT_HEAVY_USE);
        log.warning("We could not automatically use a distance matrix, expect a performance degradation.");
      }
      return dq;
    }