MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

DB2 Cursor Open

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
nivedita
Beginner


Joined: 04 Nov 2003
Posts: 22
Topics: 15

PostPosted: Tue Jan 06, 2004 9:26 am    Post subject: DB2 Cursor Open Reply with quote

Hi,

I have 1 million records in a table, when I make a select * on the table using cursors in my application a resultant table is created, how can a buffer pool hold so many rows? If there is no space in the buffer pool were will it store this result?

Any more details on FETCH and OPEN cursor?
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Tue Jan 06, 2004 10:46 am    Post subject: Reply with quote

Nivedita,

Use the Prefetch mechanism for reading a set of pages, usually 32, into the buffer pool with only one asynchronous I/O operation instead of the entire result set.

Check this link for detailed explanation of Interpreting data prefetch

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
CZerfas
Intermediate


Joined: 31 Jan 2003
Posts: 211
Topics: 8

PostPosted: Wed Jan 07, 2004 8:24 am    Post subject: Reply with quote

It is a common missunderstanding, that opening a cursor and fetching the rows leads to a physical result table in the bufferpool, from which the rows are returned to the requesting program.

This materialization only happens when the system uses "view materialization" for you (rare) or you are doing sorts (if you are using ORDER BY, DISTINCT, ...). In that case the sort tablespaces (in DSNDB07 database) are filled with the resulting rows and the fetches grab their rows from these tablespaces.

Therefor the bufferpools don't have to keep millions of rows.

regards
Christian
Back to top
View user's profile Send private message
nivedita
Beginner


Joined: 04 Nov 2003
Posts: 22
Topics: 15

PostPosted: Wed Jan 07, 2004 9:00 am    Post subject: Reply with quote

What if ORDER BY clause is not used? Then how will it work?
Back to top
View user's profile Send private message
CZerfas
Intermediate


Joined: 31 Jan 2003
Posts: 211
Topics: 8

PostPosted: Thu Jan 08, 2004 5:30 am    Post subject: Reply with quote

If you don't use a sort, then no materialization occurs. That means, that a data page is loaded into the buffer pool, scanned for qualifiying rows and those are fetched one by one by the program. If the page is exhausted, the next page is examined in the buffer pool, and the already searched page is marked as "stealable" in the buffer pool.
After that, the used space by that page is free for the buffer pool manager to be overwritten.

regards
Christian
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group