CALENDAR Functions in Oracle 26ai – Part 2

Do I Still Need a Time Dimension?

In the previous post, we explored the new CALENDAR functions introduced in Oracle 26ai — their syntax, strengths, and some subtle caveats. Now it’s time to look at the architectural question: if date logic has become easier to express directly in SQL, does that reduce the need for a dedicated time dimension in analytical models?

Continue reading

CALENDAR Functions in Oracle 26ai – Part 1

First Impressions and Practical Observations

Oracle AI Database 26ai (23.26.1) introduces new CALENDAR SQL functions. Having written countless nested TRUNC/ADD_MONTHS/TO_CHAR/LAST_DAY expressions over the years, I expected to love them immediately. They do simplify many scenarios — yet they also introduce nuances that require careful understanding before using them everywhere.

Continue reading

Fix Optimizer Estimate Issues from Implicit Conversions #JoelKallmanDay

This is not just another post about why correct data types matter. Most of you know that using the wrong data type in WHERE or JOIN conditions can trigger implicit conversions, prevent an index access path, and cause performance problems. But what if you can’t change the SQL statements, and you don’t want to redesign your data model? This post is about possible solutions in case of a wrong cardinality estimation due to an implicit data type conversion.

Continue reading

MERGE and DML RETURNING clause in Oracle 23ai

For a long time, we all “knew” that MERGE did not support a RETURNING clause. You can ask ChatGPT, Gemini, or Google, and the answer would still be the same: Nope, no luck! LLMs respond with confidence, and Google’s top results show various workarounds for the problem. I swear I saw the lifting of this restriction in the New Features Guide back when the version was still called 23c :-). Since I’m currently preparing a conference talk where this is relevant, I naturally wanted to check whether my memory was just playing tricks on me — or if it’s actually true.

Continue reading

ORA-30926 in Oracle 23ai: What’s Changed?

One of the topics I’ve found very interesting as I started blogging was the sometimes strange behavior of the MERGE statement, the reasons for ORA-30926 and what it has to do with write consistency. My first blog post about it was almost exactly ten years ago. Time for a follow up! Especially because there are some changes in Oracle 23ai.

Continue reading

When Compression Expands: The Hidden Pitfalls of HCC

Hybrid Columnar Compression (HCC) in Oracle Exadata is a prime example of how physical infrastructure can significantly enhance the efficiency of data management and analysis—when used correctly. This is an area that also affects developers and data engineers: what it is, how it works, and what to expect. If HCC is used in your project, then everyone on the team should be aware of it, including the specifics of what, where, and how it is implemented. Otherwise, there may be a few surprises, as in the example I encountered recently: instead of achieving the expected storage savings and improved performance, there was a huge increase in space consumption, along with negative performance effects. Read on to find out what happened.

Continue reading

NOT IN vs. NOT EXISTS: The Negation Battle #JoelKallmanDay

A year ago I wrote about the pitfalls of NULL values in NOT IN subqueries. This time I wanted to keep promises I made back then, dig a little deeper and also look at NOT EXISTS as another type of subquery used to filter out records based on negative matches. Is there any semantic difference and which is faster? Unfortunately, there are many myths and misconceptions around the usage of (NOT) IN and (NOT) EXISTS subqueries.

Continue reading

Online Statistics Gathering: Update 2024

Online Statistics Gathering has been introduced in Oracle 12c. I think it is a very important building block to establish a consistent approach in dealing with optimizer statistics in your ETL jobs. I have already written some posts about it a while ago (first, second and third). When I was preparing a talk about optimizer statistics for data engineers recently, I took a closer look at it again. Oracle has now continuously improved the feature over several versions and has lifted many restrictions. Let’s see what I mean.

Continue reading

SQL macros and the WITH clause

SQL macros and WITH clause are not known to be great friends: you cannot call a SQL macro in a WITH clause and if you want to define a table macro returning a query containing a WITH subquery(ies), then you won’t be able to use scalar parameters in this subquery. In the previous post I tried to explain another restriction from the technical perspective looking at the SQL macro expansion trace information. In this post I will try to understand the WITH clause related limitations using the same approach.

Continue reading

SQL Macros – Changing The Query Shape Using Parameters?

One thing I learned early on when I was getting to know SQL macros is that we cannot replace each and every part of a SQL statement with a macro. In the same way, working with table SQL macros, we cannot represent just any part of the result string by referencing parameters inside it. Sometimes we need to use string concatenation. But why it behaves this way? In this post I will look at the available trace information about SQL macro expansion during hard parse and try to understand its impact on this restriction. After that we’ll also look how to overcome it and what to consider.

Continue reading