13.07.2015 Views

SAS/ACCESS 9.2 for Relational Databases: Reference, Fourth Edition

SAS/ACCESS 9.2 for Relational Databases: Reference, Fourth Edition

SAS/ACCESS 9.2 for Relational Databases: Reference, Fourth Edition

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>SAS</strong>/<strong>ACCESS</strong> Interface to Teradata 4 Using the PreFetch Facility 801How PreFetch WorksWhen reading DBMS tables, <strong>SAS</strong>/<strong>ACCESS</strong> submits SQL statements on your behalfto Teradata. Each SQL statement that is submitted has an execution cost: the amountof time Teradata spends processing the statement be<strong>for</strong>e it returns the requested datato <strong>SAS</strong>/<strong>ACCESS</strong>.When PreFetch is enabled the first time you run your <strong>SAS</strong> job, <strong>SAS</strong>/<strong>ACCESS</strong>identifies and selects statements with a high execution cost. <strong>SAS</strong>/<strong>ACCESS</strong> then stores(caches) the selected SQL statements to one or more Teradata macros that it creates.On subsequent runs of the job, when PreFetch is enabled, <strong>SAS</strong>/<strong>ACCESS</strong> extractsstatements from the cache and submits them to Teradata in advance. The rows thatthese SQL statements select are immediately available to <strong>SAS</strong>/<strong>ACCESS</strong> becauseTeradata prefetches them. Your <strong>SAS</strong> job runs faster because PreFetch reduces the wait<strong>for</strong> SQL statements with a high execution cost. However, PreFetch improves elapsedtime only on subsequent runs of a <strong>SAS</strong> job. During the first run, <strong>SAS</strong>/<strong>ACCESS</strong> onlycreates the SQL cache and stores selected SQL statements; no prefetching is per<strong>for</strong>med.The PreFetch Option Argumentsunique_storenameAs mentioned, when PreFetch is enabled, <strong>SAS</strong>/<strong>ACCESS</strong> creates one or moreTeradata macros to store the selected SQL statements that PreFetch caches. Youcan easily distinguish a PreFetch macro from other Teradata macros. ThePreFetch Teradata macro contains a comment that is prefaced with this text:"<strong>SAS</strong>/<strong>ACCESS</strong> PreFetch Cache"The name that the PreFetch facility assigns <strong>for</strong> the macro is the value that youenter <strong>for</strong> the unique_storename argument. The unique_storename must be unique.Do not specify a name that exists in the Teradata DBMS already <strong>for</strong> a DBMStable, view, or macro. Also, do not enter a name that exists already in another<strong>SAS</strong> job that uses the Prefetch facility.#sessionsThis argument specifies how many cached SQL statements <strong>SAS</strong>/<strong>ACCESS</strong> submitsin parallel to Teradata. In general, your <strong>SAS</strong> job completes faster if you increasethe number of statements that Teradata works on in advance. However, a largenumber (too many sessions) can strain client and server resources. A valid valueis 1 through 9. If you do not specify a value <strong>for</strong> this argument, the default is 3.In addition to the specified number of sessions, <strong>SAS</strong>/<strong>ACCESS</strong> adds anadditional session <strong>for</strong> submitting SQL statements that are not stored in thePreFetch cache. Thus, if the default is 3, <strong>SAS</strong>/<strong>ACCESS</strong> actually opens up to foursessions on the Teradata server.algorithmThis argument is present to handle future enhancements. Currently PreFetch onlysupports one algorithm, SEQUENTIAL.When and Why Use PreFetchIf you have a read-only <strong>SAS</strong> job that runs frequently, this is an ideal candidate <strong>for</strong>PreFetch; <strong>for</strong> example, a daily job that extracts data from Teradata tables. To help youdecide when to use PreFetch, consider these daily jobs:3 Job 1Reads and collects data from the Teradata DBMS.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!