keep order in query ids

takes fucking 3h of my life.