Skip to Main Content

Write Great SQL Office Hours

Free tips and training every month! Subscribe for reminders and more from Office Hours. FAQ

Header container

April 20

13:00 UTC   Start Times Around the World

Description

Speeding up scalar subqueries
Scalar subqueries are an easy way to add aggregations (count, sum, etc.) to queries. But adding lots of these to one statement like this:

select …
( select count ( … ) … ),
( select avg ( … ) … ),
( select max ( … ) … )
from …

Can make your SQL significantly slower. But there's an alternative that can make this much faster:

CROSS APPLY!

Join this session to learn the ins-and-outs of scalar subqueries, how cross apply can be better, and why scalarl subqueries can be the fastest solution in some cases.
Sorry, No Recording Yet!

This session's over, but a recording of the session is not yet available.

Check out the resources on this page to explore great websites packed with lots more information - and answers to questions.

Your Experts

Chris Saxon
Chris Saxon, Oracle Developer Advocate for SQL    
Chris Saxon is an Oracle Developer Advocate and quizmaster on Dev Gym. His job is to help you get the best out of the Oracle Database and have fun with SQL! He's also part of the answer team on Ask TOM and creates YouTube videos at The Magic of SQL channel.