diff --git a/backend/ee/danswer/db/query_history.py b/backend/ee/danswer/db/query_history.py index 657d9188dc5..b1eac1debd1 100644 --- a/backend/ee/danswer/db/query_history.py +++ b/backend/ee/danswer/db/query_history.py @@ -35,7 +35,7 @@ def fetch_chat_sessions_eagerly_by_time( subquery = ( db_session.query(ChatSession.id, ChatSession.time_created) .filter(*filters) - .order_by(time_order, ChatSession.id) + .order_by(ChatSession.id, time_order) .distinct(ChatSession.id) .limit(limit) .subquery()