블로그 이미지
평범하게 살고 싶은 월급쟁이 기술적인 토론 환영합니다.같이 이야기 하고 싶으시면 부담 말고 연락주세요:이메일-bwcho75골뱅이지메일 닷컴. 조대협


Archive»


 

'fetchsize'에 해당되는 글 1

  1. 2007.11.28 대용량 Record select
 

대용량 Record select

프로그래밍/프로그래밍팁 | 2007.11.28 15:26 | Posted by 조대협

게시판 리스트등 가지고 오는데 유용하겠다.

Stmt.setFetchSize
를 이용할것..

=====
참고: ResultSet에서도 FetchSize 적용가능. 양쪽에 차이점과 성능 테스트는 시간날때 정리 필요

e244. Setting the Number of Rows to Prefetch When Executing a SQL Query

When a SQL query is executed, the number of rows of data that a driver physically copies from the database to the client is called the fetch size. If you are performance-tuning a particular query, you might be able to improve performance by adjusting the fetch size to better match the use of the query.

The fetch size can be set on a statement, in which case, all result sets created from that statement will use that fetch size. The fetch size can also be set on a result set at any time. In this case, the next time data needs to be fetched from the database, the driver will copy over as many rows as is specified by the current fetch size.

    try {
        // Get the fetch size of a statement
        Statement stmt = connection.createStatement ();
        int fetchSize = stmt.getFetchSize();
    
        // Set the fetch size on the statement
        stmt.setFetchSize(100);
    
        // Create a result set
        ResultSet resultSet = stmt.executeQuery("SELECT * FROM my_table");
    
        // Change the fetch size on the result set
        resultSet.setFetchSize(100);
    } catch (SQLException e) {
    }



====
http://sangchin.byus.net/FlashHelp/Java_sql/getfetchsize.html

3. Do batch retrieval using Statement

You can get the default number of rows that is provided by the driver. You can improve performance by increasing number of rows to be fetched at a time from database using setFetchSize() method of the statement object.

Initially find the default size by using

Statement.getFetchSize();   and then set the size as per your requirement

Statement.setFetchSize(30);

http://www.precisejava.com/javaperf/j2ee/JDBC.htm

본인은 구글 클라우드의 직원이며, 이 블로그에 있는 모든 글은 회사와 관계 없는 개인의 의견임을 알립니다.

댓글을 달아 주세요