If you are limiting yourself to SQL then there are no inner join syntax variations that guarantee better performance. It all depends on the volume, structure and cardinality of the tables and data you are joining. Incomplete joins will obviously result in slower performance and incorrect results. Understanding the data you are joining is key to writing efficient SQL inner joins.
As others already implied, there is no one size fits all when it comes to query optimization.
Assuming your data is in SAS datasets, some general guidelines though:
- Use equi-joins when possible
- Avoid OR
- Avoid function call in where/on clause
- If join presumably return a relative small result set, using indexes on join variables may help
- Allow your process to use as much memory as possible to minimize the use of swapping to spill files.
- Analyse your query behaviour by using the PROC SQL options _method and _tree, and using the global option FULLSTIMER.
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.