The Artima Developer Community
Sponsored Link

Agile Buzz Forum
Smalltalk Daily 04/28/10: Prefetch Rows with Oracle and VW

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
James Robertson

Posts: 29924
Nickname: jarober61
Registered: Jun, 2003

David Buck, Smalltalker at large
Smalltalk Daily 04/28/10: Prefetch Rows with Oracle and VW Posted: Apr 28, 2010 5:19 AM
Reply to this message Reply

This post originated from an RSS feed registered with Agile Buzz by James Robertson.
Original Post: Smalltalk Daily 04/28/10: Prefetch Rows with Oracle and VW
Feed Title: Cincom Smalltalk Blog - Smalltalk with Rants
Feed URL: http://www.cincomsmalltalk.com/rssBlog/rssBlogView.xml
Feed Description: James Robertson comments on Cincom Smalltalk, the Smalltalk development community, and IT trends and issues in general.
Latest Agile Buzz Posts
Latest Agile Buzz Posts by James Robertson
Latest Posts From Cincom Smalltalk Blog - Smalltalk with Rants

Advertisement

Today's Smalltalk Daily looks at using Oracle's pre-fetch capability with VisualWorks. If you're looking for a particular topic, you can find it with the Media Search application on our site.

The code used is below; To watch, click on the viewer:


"Connect to an Oracle database."
conn := OracleConnection new.
conn username: 'username';
password: 'password';
environment: 'ORACLEDB'.
conn connect.

sess := conn getSession.

"Drop the test table if existed."
sess prepare: 'DROP TABLE TESTTABLE';
	execute;
	answer;
	answer.

"Create a test table."
sess prepare:  'CREATE TABLE TESTTABLE(
	NUMMER int ,
	BEMERKUNG varchar2 (30)
	)';
	execute;
	answer;
	answer.

"Set the number of recrods being inserted."
loopCount := 1000.

"The SQL used to do insert."
sql := 'INSERT INTO TESTTABLE VALUES (?, ?)'.

"Insert: Using array binding."
insertTime2 := Time millisecondsToRun: [
|bindArray numArray stringArray |
    numArray := Array new: loopCount.
    stringArray := Array new: loopCount.
	1 to: loopCount do: [ :i|
		numArray at: i put: i.
		stringArray at: i put: 'test'.
	].			
	bindArray := Array with: numArray with: stringArray.
	sess prepare: sql.
         sess bindInput: bindArray;
		execute;
		answer;
		answer.
].

"Print out the miliseconds spent."
Transcript 
	cr; 
	show: 'Time spent using array binding: ', insertTime2 asFloat printString.

"Set times to repeat."
loopCount := 1.

"Set the SQL to do the fetch."
sql := 'SELECT * from TESTTABLE'.

"Default value of prefetch rows is 1."
sess setPrefetchRows: 1.

selectTime1 := Time millisecondsToRun: [
	1 to: loopCount do: [ :i|
		sess prepare: sql;
		execute.
		ans := sess answer.
		res := ans upToEnd.
    	].
].

"Print out the miliseconds spent."
Transcript 
	cr; 
	show: 'Time spent when prefetch rows  is 1: ', selectTime1 asFloat printString.

"Set prefetch rows to 100."
sess setPrefetchRows: 100.

selectTime2 := Time millisecondsToRun: [
	1 to: loopCount do: [ :i|
		sess prepare: sql;
		execute.
		ans := sess answer.
		res := ans upToEnd.
    	].
].

"Print out the miliseconds spent."
Transcript 
	cr; 
	show: 'Time spent when prefetch rows  is 100: ', selectTime2 asFloat printString.

"Set prefetch rows to 500."
sess setPrefetchRows: 500.

selectTime3 := Time millisecondsToRun: [
	1 to: loopCount do: [ :i|
		sess prepare: sql;
		execute.
		ans := sess answer.
		res := ans upToEnd.
    	].
].

"Print out the miliseconds spent."
Transcript 
	cr; 
	show: 'Time spent when prefetch rows is 500: ', selectTime3 asFloat printString.


If you have trouble viewing that directly, you can click here to download the video directly

You can also watch it on YouTube:

Technorati Tags: , , ,

Read: Smalltalk Daily 04/28/10: Prefetch Rows with Oracle and VW

Topic: Industry Misinterpretations 185: Across Smalltalks Part 2 (AAC) Previous Topic   Next Topic Topic: Portable Eclipse projects & goodbye to unbound classpath container (JRE) errors

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use