OFFSET vs. ROW_NUMBER()

后端 未结 2 1753
渐次进展
渐次进展 2020-12-13 02:11

As we know, Postgresql\'s OFFSET requires that it scan through all the rows up until the point it gets to where you requested, which makes it kind of useless for pagination

2条回答
  •  旧时难觅i
    2020-12-13 03:06

    Use a CURSOR for a large resultset, will be much faster. For small result sets the LIMIT OFFSET construction works fine, but it has it's limits.

    ROW_NUMBER is a nice thing, but not for pagination. You end up with bad performance because of sequential scan's.

提交回复
热议问题