The Artima Developer Community
Sponsored Link

Agile Buzz Forum
Smalltalk Daily 04/27/10: Using LOBs with Oracle and VisualWorks

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/27/10: Using LOBs with Oracle and VisualWorks Posted: Apr 27, 2010 3:59 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/27/10: Using LOBs with Oracle and VisualWorks
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 LOBs with Oracle (version 9 and up) 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:


"The following are examples to demonstrate performance improvement when 
setting the right size of LOB buffers."

"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 TestLob';
	execute;
	answer;
	answer.

"Create a test table."
sess prepare: 'CREATE TABLE TestLob (A CLOB, B BLOB, C INTEGER)';
	execute;
	answer;
	answer.

conn begin.
insertSQL := 'INSERT INTO TestLob (a, b, c) VALUES (?, ?, ?)'.
sess prepare: insertSQL.
clobLength := 2097152. "2MB"
blobLength := 2097152. "2MB"
clob := String new: clobLength withAll: $a.
blob := ByteArray new: blobLength withAll: 1.

sess lobBufferSize: 32768.  "32KB is the default buffer size for read/write Large Objects."

insertTime1 := Time millisecondsToRun: [
		sess bindInput: (Array with: clob with: blob with: 1);
		execute;
		answer;
		answer.
].

"Print out the miliseconds spent."
Transcript 
	cr; 
	show: 'Time spent for insert when lobBufferSize is 32KB ', insertTime1 asFloat printString.

"Set lobBufferSize to 1MB"
sess lobBufferSize: 1048576.  "1MB"

insertTime2 := Time millisecondsToRun: [
		sess bindInput: (Array with: clob with: blob with: 2);
		execute;
		answer;
		answer.
].

"Print out the miliseconds spent."
Transcript 
	cr; 
	show: 'Time spent  for insert when lobBufferSize is 1MB: ', insertTime2 asFloat printString.

conn commit.

conn begin.
sess := conn getSession.
selectSQL := 'SELECT * FROM TestLob'.
sess answerLobAsValue. "Get LOBs back as values."
sess defaultDisplayLobSize: 2097152. "We want every byte of the LOBs returned."

sess lobBufferSize: 32768.  "32KB is the default buffer size for read/write Large Objects."
selectTime1 := Time millisecondsToRun: [ | ans1 |
		sess prepare: selectSQL;
		execute.
		ans1 := sess answer.
		ans1 upToEnd.
].

"Print out the miliseconds spent."
Transcript 
	cr; 
	show: 'Time spent for select when lobBufferSize is 32KB ', selectTime1 asFloat printString.

"Set lobBufferSize to 1MB"
sess lobBufferSize: 1048576.  "1MB"

selectTime2 := Time millisecondsToRun: [ | ans2 | 
		sess prepare: selectSQL;
		execute.
		ans2 := sess answer.
		ans2 upToEnd.
].

"Print out the miliseconds spent."
Transcript 
	cr; 
	show: 'Time spent  for select when lobBufferSize is 1MB: ', selectTime2 asFloat printString.

conn rollback.

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/27/10: Using LOBs with Oracle and VisualWorks

Topic: You should probably watch this, if you haven't already Previous Topic   Next Topic Topic: Smalltalk Daily 04/23/10: Using Prefetch with Oracle and ObjectStudio

Sponsored Links



Google
  Web Artima.com   

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