I remember being at an Oracle conference a few years ago, and I attended a session that was related to SQL Tuning. One of the things that was discussed in this lecture was Oracle Single Table Hash Clusters, and I… Read More
Calculating Scalar Subquery Cache Size
Whenever you have a scalar subquery in Oracle, there are a few different options that Oracle can use for executing the subquery. Oracle can either run the query once for each row returned by the records in the from clause.… Read More
How to Accidentally “Untune” a Query
Suppose one day that you’re at your desk, when you get a telephone call from someone complaining that a query is running slow. You’re given the following setup: And the query that you’re trying to tune looks like this: If… Read More
Filters in the JOIN Clause vs. WHERE Clause: Does It Matter?
Here’s a question I’ve been asked multiple times from multiple people: “Does it matter I put filters in the join clause vs in the WHERE clause? And if so, which one is better?” Example: vs. So does it matter? Answer:… Read More
When to Use APPROX_COUNT_DISTINCT
Since Oracle 12.1, users have had the ability to use the APPROX_COUNT_DISTINCT() function. This function is supposed to be significantly faster than a COUNT(DISTINCT …). Does it really offer that big of a payout? Let’s see: First, let’s make a… Read More
Over-The-Fence Tuning
One of the best tips on SQL Tuning I can offer you is this: DO NOT DO OVER-THE-FENCE TUNING. It’s taken me years to finally figure this out. What do I mean by over-the-fence SQL Tuning? It goes like this:… Read More
What is Cost? How Can I Use It to Tune SQL?
When most people first start learning to tune SQL, they develop a fascination with this mysterious column on the execution plan called “cost.” What is cost? And how can you use it to tune SQL? So here’s, high level, what… Read More
How to tell if you have a multi-pass hash join
A hash join can be either an optimal hash join, a one-pass hash join, or a multi-pass hash join. Optimal hash joins – The entire build table fits nicely into memory One-pass hash joins – The build table did not… Read More
What is a “Skinny Table” (aka “Narrow Table” or “Strip Table”)?
A skinny table (also called a “Narrow Table” or a “Strip Table”) is a table that has very few columns and/or very narrow columns. This means the table has an small average row length. You can make a skinny table… Read More