SQL LIMIT vs. JDBC Statement setMaxRows. Which one is better?

后端 未结 5 1683
离开以前
离开以前 2021-02-08 20:13

I want to select the Top 10 records for a given query. So, I can use one of the following options:

  • Using the JDBC Statement.setMaxRows() method
  • Using LIMI
5条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-08 20:42

    The advantage of setmaxrows is that you can create universal statements, valid in Postgres, Oracle, Mysql etc As Oracle is using rownum syntax, postgres - limit, msqsql - top

    Speedwise it seems like no difference.

提交回复
热议问题