def _normalize_sql(sql, maxlen=150):
    """Collapse whitespace and middle-truncate if needed."""
    out = ' '.join(sql.split())
    if len(out) > maxlen:
        i = int(maxlen / 2 - 4)
        out = (out[0:i] +
               ' . . . ' +
               out[-i:None])
    return out