Hi Team,
Lets say I have source table of 10 million records.
My sql query / data step using defined libname statement has retrieved the result set with 1 million records.
I have imposed inobs=1, outobs=1 (proc sql) / obs=1 (data step) and so, my output dataset created has only 1 record.
When we enable trace log on a data step with obs=5 in set statement , but still see that internal select query seems created with no filters.
Data tgt.arrg_5 ;
ODBC_1: Prepared: on connection 0
SELECT * FROM MYDB.DWH_ARRG
set source.DWH_ARRG(obs=5);
run;
ODBC_1: Prepared: on connection 0
SELECT * FROM MYDB.DWH_ARRG
set source.DWH_ARRG(obs=5);
run;
ODBC_2: Executed: on connection 0
Prepared statement ODBC_1
My query:
Is the result set pulled into SAS environment ? Is it stored somewhere ?
I do not want entire result set to be pulled into SAS environment when I impose obs=1 / inobs=1
Kindly help to explain the processing at the background.
Your code makes no sense, as you mix SQL and data step statements.
Please post your real code.
Below is the detail after enabling trace log :
1 options sastrace=',,,ds' sastraceloc=saslog nostsuffix;
2
3
4 libname tgt "/abc/xyz";
NOTE: Libref TGT was successfully assigned as follows:
Engine: V9
Physical Name: /abc/xyz
ODBC: AUTOCOMMIT is YES for connection 0
5 libname bq ODBC DSN="xxx" schema="TD";
NOTE: Libref BQ was successfully assigned as follows:
Engine: ODBC
Physical Name: GoogleBQ
6 Data tgt.arrg_5 ;
ODBC_1: Prepared: on connection 0
SELECT * FROM TD.DWH_ARRG
7 set bq.DWH_ARRG(obs=5);
8 run;
ODBC_2: Executed: on connection 0
Prepared statement ODBC_1
NOTE: There were 5 observations read from the data set BQ.DWH_ARRG.
The obs=5 (a pure SAS dataset option) is not handed over to the view that's behind the ODBC, so it reads everything and transmits it to SAS, where only 5 observations are taken.
My .02 $
Can you tell from the performance of the query whether SAS pulled over all of the records and then subset to just the first 5?
It is possible that the traces that SAS shows do not include commands that would limit the number of records returned from a query.
@Kurt_Bremser @Tom @Reeza @Timmy2383 @VDD
Data tgt.arrg_5 ; set bq.DWH_ARRG(obs=5); run;
"It is possible that the traces that SAS shows do not include commands that would limit the number of records returned from a query."
As a pure technical option, you could monitor network traffic between the SAS and DBMS servers to see how much data is passed.
And it should be possible to log the queries on the DBMS side.
And I would submit this whole issue to SAS technical support; you might have found something that is not really a bug, but suboptimal at least.
PS is DWH_ARRG a table or a view in the DBMS?
@Kurt_Bremser DWH_ARRG is a table in DBMS.
If you can verify that the DBMS reads the whole table (and from your previous post I guess we can assume that), then this is (IMO) a problem for SAS Technical Support. It's not a big thing (as the end result will be correct), but it's a waste of time and resources with large DBMS tables.
The SAS Users Group for Administrators (SUGA) is open to all SAS administrators and architects who install, update, manage or maintain a SAS deployment.
SAS technical trainer Erin Winters shows you how to explore assets, create new data discovery agents, schedule data discovery agents, and much more.
Find more tutorials on the SAS Users YouTube channel.