BookmarkSubscribeRSS Feed
set_all__
Fluorite | Level 6

I have two datasets - Big (100 million rows) and small (200,000 rows). The Big dataset is indexed by a unique key.

 

I have two queries in sequence doing a left join from the small to the big dataset which looks like this:

 

 

proc sql;
select *
from a left join b
on a.key=b.key;
quit;

The first time the query runs for 20-30 minutes, but the second time takes only 2-3 minutes. Why does this happen? Is it possible to do something to reduce the runtime for the first query as well?

4 REPLIES 4
Bal23
Lapis Lazuli | Level 10

The big dataset does need that much time to run.

 

Below is some information might help.

 

http://analytics.ncsu.edu/sesug/2011/BB08.Lafler.pdf

 

 

There are a number of common reasons for slow-running queries and updates:

  • Slow network communication.

  • Inadequate memory in the server computer, or not enough memory available .

  • Lack of useful statistics

  • Lack of useful indexes.

  • Lack of useful indexed views.

  • Lack of useful data striping.

  • Lack of useful partitioning.

SASKiwi
PROC Star

The most likely reason for the faster second join is that the data has been cached by your server hardware / OS. You could prove this by swapping the queries around, if possible, to see a similar effect.

 

A faster solution would be to use a SAS format built from the small table to do the data lookup. That way you avoid joining entirely. 

jklaverstijn
Rhodochrosite | Level 12

Your "small" dataset was probably found in the filesystem cache the second time. A normal behaviour that speeds up access to frequently used files by keeping them in memory.

LinusH
Tourmaline | Level 20
Before jumping to any conclusions you need more information.
Add
Options msglevel =i fullstimer;
This will give more information about basic processing and systems constraints.

Proc SQL _method;
Will give you the SQL plan.
Data never sleeps

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!

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