code: public int getNumberOfUniqueContributorsBeforeRevision(final int revisionID,
              boolean onlyRegistered)
          throws WikiApiException
      {
  
          try {
              if (revisionID < 1) {
                  throw new IllegalArgumentException();
              }
  
              int articleID = getPageIdForRevisionId(revisionID);
              Timestamp ts = getRevision(revisionID).getTimeStamp();
  
              int contrCount = 0;
              PreparedStatement statement = null;
              ResultSet result = null;
  
              try {
                  // Check if necessary index exists
                  if (!indexExists("revisions")) {
                      throw new WikiInitializationException(
                              "Please create an index on revisions(ArticleID) in order to make this query feasible.");
                  }
  
                  StringBuffer sqlString = new StringBuffer();
                  sqlString
                          .append("SELECT COUNT(DISTINCT ContributorName) FROM revisions WHERE ArticleID=? AND Timestamp<?");
                  if (onlyRegistered) {
                      sqlString.append(" AND ContributorIsRegistered=1");
                  }
  
                  statement = connection.prepareStatement(sqlString.toString());
  
                  statement.setInt(1, articleID);
                  statement.setLong(2, ts.getTime());
                  result = statement.executeQuery();
  
                  // Make the query
                  if (result == null) {
                      throw new WikiPageNotFoundException("The article with the ID " + articleID
                              + " was not found.");
                  }
  
                  if (result.next()) {
                      contrCount = result.getInt(1);
                  }
              }
              finally {
                  if (statement != null) {
                      statement.close();
                  }
                  if (result != null) {
                      result.close();
                  }
              }
  
              return contrCount;
  
          }
          catch (WikiApiException e) {
              throw e;
          }
          catch (Exception e) {
              throw new WikiApiException(e);
          }
      }
docs: Returns the number of unique contributors to an article that have contributed before the
  given revision.
  
  In order to make this query fast, create a MySQL-Index (BTREE) on the ArticleID in the
  revisions-table.
  
  @param revisionID
  revision before which to count the contributors
  @param onlyRegistered
  defines whether to count only registered users {@code true}, or all users (false)
  @return the number of unique contributors to the article
  
  @throws WikiApiException
  if an error occurs