
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.