sreda, 27. november 2013

Faster fetch from DB2 cursor

If you are using cursors in DB2 procedures, for example, and you don't use them to update the data, you can significantly improve fetch performance using FOR READ ONLY:

    DECLARE XSQL                    VARCHAR(10240);
    DECLARE XSQLSTATE_1             STATEMENT;
    DECLARE XRESULT_SET_1           CURSOR WITH RETURN TO CLIENT FOR XSQLSTATE_1;

    SET XSQL = 'SELECT * FROM SYSIBM.SYSDUMMY1 FOR READ ONLY WITH UR';
    PREPARE XSQLSTATE_1 FROM XSQL;
    OPEN XRESULT_SET_1;

XRESULT_SET_1 is returned back to the client, so it can iterate over the data.

Ni komentarjev: