def METHOD_NAME(self):
    """If max_items is set, return an expression to limit the query."""
    max_items = config.val.completion.web_history.max_items
    # HistoryCategory should not be added to the completion in that case.
    assert max_items != 0
    if max_items < 0:
        return ''
    min_atime = self._database.query(' '.join([
        'SELECT min(last_atime) FROM',
        '(SELECT last_atime FROM CompletionHistory',
        'ORDER BY last_atime DESC LIMIT :limit)',
    ])).run(limit=max_items).value()
    if not min_atime:
        # if there are no history items, min_atime may be '' (issue #2849)
        return ''
    return "AND last_atime >= {}".format(min_atime)