Sample Header Ad - 728x90

postgresql row number function with large amount of result

0 votes
0 answers
19 views
I have a sql like this in PostgreSQL 14: SELECT biz_id login_time, ROW_NUMBER() OVER (PARTITION BY biz_id ORDER BY login_time DESC) AS priority_rn FROM example then I need to get the first row in the outer query. Now I facing a issue that the inner query result too large(>3000000 rows), it look like this row number have a performance issue(>4min to get the result). is it possible to optimize this query? or I need to change to another way?
Asked by Dolphin (939 rep)
May 8, 2025, 09:04 AM