BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sdut
Fluorite | Level 6

Hi

 

We have recently added SAS/ACCESS for JDBC to our environment (9.4m7) and we are facing a behaviour for which we would like to have a workaround.

Consider this code:

libname mylib jdbc classpath="D:\LIB"
class="xxxx"
URL="xxxx"
user=xxxx
password=xxxx; /*LIBNAME BASIC STATEMENT IS CORRECT : WE CAN ACCESS ITS CONTENTS*/

proc sql;
create table ttt as 
	select * 
	from mylib.a 
	LEFT join mylib.b on a.age =b.age 
	LEFT JOIN mylib.c on c.key = a.key
	where a.field < 1000;

quit;

When running it, SAS split the two join and sends three queries to the source system, as opposed to just pushing that query down to the database system.

It causes a lot of performance issues, our database tables can get quite huge to retrieving the entire thing takes a very long time.

Is there a way to "hint" at SAS that the database is able to handle that double outer join?

 

If we do inner joins instead of outer joins, then the sas query is pushed in a single sql query to our database.

 

Thank you in advance !

1 ACCEPTED SOLUTION

Accepted Solutions
sdut
Fluorite | Level 6

Hi

FYI, an update on this.

 

I have opened a support track.

It highlighted a problem with the driver provided by our database vendor. The vendor provided us with a hotfix and that fixed the original problem.

 

However, it uncovered a limitation of the SAS/ACCESS JDBC and ODBC interfaces. They do not support mixing outer with inner joins. In that case the queries are broken down in multiple sub-queries sent to the database, which causes a lot of problems for us.

I have opened a SAS ballot to request an enhancement to support that outer/inner join mixing - or at least to give a flag to indicate that the underlying data source supports inner and outer joins together. You're obviously all welcome to upvote it 😊

https://communities.sas.com/t5/SASware-Ballot-Ideas/JDBC-SAS-ACCESS-More-options-for-query-pushdown-...

 

Thanks for your help !

View solution in original post

5 REPLIES 5
SASKiwi
PROC Star

Try SQL Passthru where you write your database's SQL syntax inside the brackets:

proc sql;
 connect using mylib;
  create table ttt  as 
  select * from connection to mylib
  (SELECT *
   FROM a as A
   LEFT JOIN b as B
   ON A.age = B.age
   LEFT JOIN c as C
   ON A.key = C.key
   where a.field < 1000
   )
  ;
quit;
LinusH
Tourmaline | Level 20

According to the documentation, SAS says that some DBMS doesn't support where statements in combination with outer joins.

This is not specifically stated under the JDBC section, but I could be worth to try without it to see if that is the issue.

Also, set these option, it might give som information why SAS/ACCESS to JDBC/DB doesn't accept your query:

options sastrace=',,,d' sastraceloc=saslog nostsuffix msglevel=i;
Data never sleeps
sdut
Fluorite | Level 6

Hi both,

Thank you for your answers.

 

@LinusH The DBMS supports that exact SAL statement without issue, we have tried directly with a query software against that database and that works perfectly as intended. The log trace didn't show anything valuable. Is there no way to tell the SAS execution engine that this DBMS is able to handle that type of statement? I'm fairly new to SAS so any help on that end would be greatly appreciated.

 

@SASKiwi SQL Passthrough does the trick, however that would not work for joins done with the SAS EG GUI.

SASKiwi
PROC Star

I suggest you open a track with SAS Tech Support on this and then post any updates back here. Do you by any chance have SAS/ACCESS to ODBC where you can try exactly the same thing? SAS's JDBC engine is relatively new whereas ODBC has been around a long time. 

sdut
Fluorite | Level 6

Hi

FYI, an update on this.

 

I have opened a support track.

It highlighted a problem with the driver provided by our database vendor. The vendor provided us with a hotfix and that fixed the original problem.

 

However, it uncovered a limitation of the SAS/ACCESS JDBC and ODBC interfaces. They do not support mixing outer with inner joins. In that case the queries are broken down in multiple sub-queries sent to the database, which causes a lot of problems for us.

I have opened a SAS ballot to request an enhancement to support that outer/inner join mixing - or at least to give a flag to indicate that the underlying data source supports inner and outer joins together. You're obviously all welcome to upvote it 😊

https://communities.sas.com/t5/SASware-Ballot-Ideas/JDBC-SAS-ACCESS-More-options-for-query-pushdown-...

 

Thanks for your help !

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 781 views
  • 5 likes
  • 3 in conversation