Quantcast
Channel: Teradata Developer Exchange - Blog activity for NetFx's blog
Viewing all articles
Browse latest Browse all 56

Speed up Large Object (LOB) retrieval with CommandBehavior.SequentialAccess - blog entry by NetFx

$
0
0
Cover Image: 

Teradata Database supports Inline and Deferred Large Object Retrieval modes. The LOB retrieval modes control the content of rows and accessibility of LOB columns. 

1- Deferred Mode: Teradata Database returns a Locator (conceptually a pointer)  to the Data Provider. A Locator is a unique identifier within the Context of current result-set. The Data Provider must send the Locator back to the Teradata Database to retrieve the LOB Data. For example, given the following SQL Command:

SELECT "First Name", "Last Name", Address, Photo, Age FROM Customers

Teradata Database returns the following result set to the Data Provider: 

First Name

Last Name

Address

Photo

Age

John

Smith

1 Main St, Poway, CA 99111

LOCATOR#1

32

Rich

Jackson

122 2nd St, El Segundo, CA 92222

LOCATOR#2

55

 The Data Provider executes  two additional queries to retrieve the Photos. 

SELECT ? -- Pass LOCATOR#1 for the parameter

SELECT ? -- Pass LOCATOR#2 for the parameter

 

2- Inline Mode: Teradata Database returns LOB Data within the result set row. In this mode LOBs are very similar to any other system types (e.g. Integer, VarChar …).  For example, given the following SQL Command:

SELECT "First Name", "Last Name", Address, Photo, Age FROM Customers

Teradata Database returns:

First Name

Last Name

Address

Photo

Age

John

Smith

1 Main St, Poway, CA 99111

32

Rich

Jackson

122 2nd St, El Segundo, CA 92222

55

  

In this example, the Data Provider executes one Command to retrieve the two rows of data in Inline mode vs. three Commands in Deferred mode.

 

The .NET Data Provider for Teradata supports inline and deferred modes. By default (i.e. CommandBehavior.Default) the Data Provider retrieves LOBs in deferred mode. In this mode an Application can randomly access the fields of a row and it can even retrieve the LOB fields two or more times. For example an application can retrieve fields in any order starting with John's photo (Ordinal #3) followed by his address (Ordinal #2) and Age (Ordinal #4). The Default behavior provides the highest level of flexibility. However the default behavior adds additional round-trips to the Teradata Database and back; one additional round-trip for each LOB.

The Data Provider uses Inline LOB retrieval mode when CommandBehavior is set to SequentialAccess. In this mode all fields must be accessed sequentially starting from Ordinal #0. For example an application must retrieve First Name, Last Name, and Address before Photo. The Data Provider throws an exception when an application attempts to retrieve First Name, Last Name or Address column after it starts retrieving a Photo. In this mode flexibility is sacrificed for Performance.

SequentialAccess (or Inline mode) can greatly enhance data retrieval performance when LOBs are small (e.g. Geospatial data) or when the network latency is high. However you must consider features vs. performance. For example an application cannot use TdDataReader.GetTdBlob or TdDataRreader.GetTdClob methods in SequentialAccess mode.

Ignore ancestor settings: 
0
Apply supersede status to children: 
0

Viewing all articles
Browse latest Browse all 56

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>