def METHOD_NAME(
    self, query: PostgresQuery, prepare: Optional[bool] = None
) -> Tuple[Prepare, bytes]:
    """
    Check if a query is prepared, tell back whether to prepare it.
    """
    if prepare is False or self.prepare_threshold is None:
        # The user doesn't want this query to be prepared
        return Prepare.NO, b""
    key = self.key(query)
    name = self._names.METHOD_NAME(key)
    if name:
        # The query was already prepared in this session
        return Prepare.YES, name
    count = self._counts.METHOD_NAME(key, 0)
    if count >= self.prepare_threshold or prepare:
        # The query has been executed enough times and needs to be prepared
        name = f"_pg3_{self._prepared_idx}".encode()
        self._prepared_idx += 1
        return Prepare.SHOULD, name
    else:
        # The query is not to be prepared yet
        return Prepare.NO, b""