BookmarkSubscribeRSS Feed
ath_123
Calcite | Level 5

Hi ,

 

I am having a PROC SQL statement which select count(*) from an Oracle table. The table is having huge number of records. Is there any options/statements or any other way with which I can optimize the query to yield the result much faster.

3 REPLIES 3
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Without seeing the code or the data its hard to say, but one thing you can do is to pass through the processing to the database and then retrieve the result:

 

proc sql;
  connect to oracle (path=...);
  create table WANT as
  select * from connection to oracle (select count(*) from <your_table>);
quit;

This will pass the select count(*) from your table through to the database to process, then it will return the result to SAS.  You could also try filtering your data, I mean count(*) is not the most efficient solution, you will want to be looking at the minimum data, so where out any records you don't need, drop any columns you don't need - * is quite frowned upon:

select count(VAR) 
from (select VAR from HAVE where COND="YES")  
/* Minimise the data with where and only take variables you need */

 

LinusH
Tourmaline | Level 20
Chances are that this query already are being sent to the RDBMS. Use
Options msglevel = I sastrace = ',,,d' sastraceloc = saslog nostsuffix;
to find out.
If this is a case this a matter of Oracle tuning - talk to the DBA.
Data never sleeps
Ksharp
Super User

Yeah. It is Oracle DBA job. You can query Meta Data(Dictionary table) to get the number of records of a Oracle Table.

Ask Oracle DBA how to write this kind of Oracle SQL statement, and Pass - through it by SAS Proc sql .

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 3 replies
  • 840 views
  • 0 likes
  • 4 in conversation