I want to select the top 10 entries, I can use one of them:
My question is: what are the advantages and disadvantages between them?
In most cases, you want to use the offer LIMIT, but at the end of the day both will achieve what you want. This answer focuses on JDBC and PostgreSQL, but applies to other languages and databases that use a similar model.
LIMIT
JDBC documentation for Statement.setMaxRowssays
Statement.setMaxRows
If the limit is exceeded, extra lines are silently discarded.
. , . PostgreSQL JDBC , . maxRows AbstractJdbc2ResultSet. maxRows QueryExecutorImpl.
maxRows
AbstractJdbc2ResultSet
QueryExecutorImpl
, PostgreSQL LIMIT :
, , , .
setmaxrows , , Postgres, Oracle, Mysql .. Oracle rownum, postgres - limit, msqsql - top
.
setFetchSize. JDBC , , ResultSet, , .
setMaxRows , ResultSet, Statement, .
, 2 JDBC API, setFetchSize , 100K . , ArrayList Jasper.
, , , , , , , "TOP 1" numrows = 1. , " ", "". . , "" , . . , JDBC y/n. , , , , ... db , , "Speedwise " ... . , , , , ... "TOP 1"...
Source: https://habr.com/ru/post/1605957/More articles:Skipping lines of code based on available features (s) / toolbars - debuggingQQuickWidget делает бескаркасный и прозрачный QMainWindow полностью исчезающим - qtStop users by clicking on the stable branch in the mercury - mercurialHow can I read a tab delimited file in a multidimensional array using Linq? - c #What is the difference between Statement.setMaxRows and Statement.setFetchsize in Hive - javaspringboot + spring mvc + cas = 404? - springCan one element of a structure access another element in C? - cMVC application runs slowly for every page after restart - performanceExtract multiple instances of text from a MySQL column restricted to certain characters - sqlHTML / CSS: focus a paragraph - javascriptAll Articles