We have a problem about SAS view performance when its getting a query from multiple tables -that contains reasonable large data- from database. We have a simple loan portfolio data that has nearly 600k rows and 40 columns for a day and we have it for 2 years period. It has some inner joins from differnt tables also (2-3 more tables) IT department create views for us and we find that its working so slowly. When you try to drag it to the process flow, it takes 30 minutes to have a view.
I read that (i m not sure its true or not) if you r getting a view that contains multiple join queries from different table, SAS is getting all data inside and make it ready for you for view usage. Is it true? as i mentioned above, i have to wait for neasrly 30 minutes to have a view from SAS and the data is not so large.
When we try it with a view that is getting one table query the perfomance is great. Also we put the data to sas table and try to view it. performance is great als this time. But i dont want to create a new copy database that contains same tables in SAS server.
Is anybody knows a solution to handle this poor performans of a view that contains multiple queries joined by a query?
p.s. we also try proc sql for just one day data. It is not also working properly.
Thanks.
The details matter.
My guess is that you are using SAS code to merge multiple tables from an external database. If SAS cannot figure out how to push the query into the database then it will be forced to pull all of the data out of the data base and then do the view.
If you can configure the views/joins to be done in the database then you should see better performance as there should be less data transferred from the database to SAS. Of course then you will need to take steps to optimize the performance of those queries in the external database.
@tansel wrote:
thanks for your reply. I will forward t to IT dept very soon. Now we r talking about creating the table at orijinal database then get a single view at SAS or directly create a table at SAS instead of view. But im not sure because of memory issues.It should be resolved with view option.
A view is sort of encapsulated SQL code that gets executed when you're using the view. As such a physical table will consume less resources during run-time than a view because with a table no such extra processing needs to happen.
Very often the bottleneck is the data transfer from the database to SAS. For this reason you want to reduced data volumes on the database first before moving the data to SAS for further processing.
When joining tables from a database then SAS will try to push the whole query to the database for processing and only return the result set (=minimize the data transfer between the DB and SAS).
If you add options sastrace=',,,d' sastraceloc=saslog nostsuffix; at the beginning of your code then the SAS log will show you which part of a query SAS could actually push to the database and which part got executed on the SAS side. Using this option and analysing the log is an important step in performance analysis. Sometimes a few changes to a query will allow SAS to push everything to a DB. Also: Be aware that SAS can't push all functions to the database so as soon as you use one of these non-compatible functions data will get pulled into SAS.
For the actual data transfer: There is a libname option readbuff=<some value> with a default which is almost always too low. Setting this option to a higher value can increase data transfer significantly.
And last but not least:
If possible then create the views on the database and not within SAS. This guarantees that view execution will always happen on the database side and it also allows to use database specific SQL syntax for query optimisation.
thanks to everyone. we did it finally. we created a temporary table on db side (includes joins etc) and executed query with it. Then we took the view from it with a simple query without joins. It worked in seconds.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.