Re: JDBC stored procs doc patch
От | Fernando Nasser |
---|---|
Тема | Re: JDBC stored procs doc patch |
Дата | |
Msg-id | 3F27EC4B.5020701@redhat.com обсуждение исходный текст |
Ответ на | JDBC stored procs doc patch (Nic <nferrier@tapsellferrier.co.uk>) |
Список | pgsql-jdbc |
Nic wrote: > >>>+<programlisting> >>>+Statement st = db.createStatement(); >>>+// Turn use of the cursor on. >>>+st.setFetchSize(50); >>>+ResultSet rs = st.executeQuery("SELECT * FROM mytable"); >>>+while (rs.next()) { >>>+ System.out.print("a row was returned."); >>>+} >>>+rs.close(); >>>+// Turn the cursor off. >>>+st.setFetchSize(0); >>>+ResultSet rs = st.executeQuery("SELECT * FROM mytable"); >>>+while (rs.next()) { >>>+ System.out.print("many rows were returned."); >>>+} >>>+rs.close(); >>>+// Close the statement. >>>+st.close(); >>>+</programlisting> >>>+ </para> >>>+ >>>+ >> >> >>I do not understand what the example is supposed to show. The fetch >>size is transparent to the user (it is just a hint to the driver about >>what should be the best strategy) so you should be able to get all the >>rows, and the same number of them, as you go doing rs.next(). > > > The example is supposed to show that you get different behaviour with > different values. The latency on the first call with be lower (with > large result sets) than the latency on the second call. > I see, the person running it is supposed to notice a small delay between the 50th and the 51st "a row was returned.", right? Maybe you can make it more obvious. You can number the lines printed and add a comment saying that small delays _may_ be noticed every 50 lines. Also, to make the example more realistic you could add some time measurement for the two blocks (with and without setting the fetch size) and suggest that the programmer play with the fetch size to find out what is the best setting for his application needs. Thanks for the clarifications. Best regards, Fernando -- Fernando Nasser Red Hat Canada Ltd. E-Mail: fnasser@redhat.com 2323 Yonge Street, Suite #300 Toronto, Ontario M4P 2C9
В списке pgsql-jdbc по дате отправления: