When YQL runs a SELECT statement, it accesses a back-end datasource, typically by calling a Web service. Remote filters and limits are implemented by the back-end Web service. Local processing (including local filters and limits) is performed by the YQL Web Service on the data it fetches from the back-end Web service. As shown by the following example, whether an operation is remote or local affects the data returned to the application that calls the SELECT statement.
The following SELECT statement gets place information matching the string "San Francisco" from the
The steps that follow show the order in which YQL processes the remote and local parts of the SELECT statement:
geo.placestable, at the following URL:
By calling this URL, YQL gets the first 50 items that match the SELECT statement's
q(San Francisco). The
q element is
text input key for the
geo.places table. Although the remote filter in
the SELECT is set to 100, to improve efficiency, YQL only fetches 50 items each time it
calls the Web service.
lang in ("es"). This filter selects an item if the value
langfield (column) is "es". From the set of the 50 items, YQL finds a subset of items that match the local filter.
country.contentfields, which are specified after the SELECT keyword.
startparameter to 50, to get the next 50 rows:
On this second set of 50 items, YQL applies the local filter, and again only finds a subset of items matching the local filter.
country.contentfields, exist. Let's suppose that YQL has already found 5 matches from the two sets of results. Because the local limit of 5 has been reached, YQL does not call the GeoPlanet API again.
sortfunction, ordering the data by the
country.contentfields) to the calling Web application.
The following table identifies whether an element in the SELECT statement is processed locally or remotely by YQL.
|Syntax Element in SELECT||Local or Remote||Section With Details|
|Columns or asterisk after the SELECT keyword.||Local||Specifying the Elements Returned (Projection)|
|Remote limit and offset, indicated by integers in parentheses after the table name.||Remote||Remote Limits|
|Remote filter expression in the WHERE clause. The allowed operators are the equal sign or IN. The value compared is an input key for the back-end datasource.||Remote||Remote Filters|
|Local filter expression in the WHERE clause. Various operators are allowed, including LIKE and MATCH. The value compared is a field (column) in the data returned by the query.||Local||Local Filters|
|LIMIT and OFFSET keywords after the WHERE clause.||Local||Local Limits|
|Sort and other functions after the pipe (|) symbol.||Local||Sort and Other Functions|