Optimierung mit mehreren Unbekannten

Franck Pachot hat im dbi Blog eine kleine Serie von Artikeln begonnen, in denen er eines der klassischen Anti-Pattern der SQL Entwicklung untersucht - generische Queries mit mehreren AND-verknüpften Bedingungen der Form:
column_value = NVL(:bindewert, column_value)
Diese Konstrukte dienen dazu, dem Anwender die Möglichkeit zu geben, eine Ergebnismenge durch eine Eingabe einzuschränken, wobei der Verzicht auf eine Eingabe keine Einschränkung nach sich ziehen soll. Von der Anwendungslogik her ist das durchaus plausibel, aber der Optimizer (more...)

End Your Data Modeling Pain

Tired of hand drawn data models, or models drawn in Visio or even PowerPoint? Still limping along on an old Oracle Designer repository? Can’t afford the license for your current modeling tool anymore? Or maybe your shop has no documented data model diagrams at all (horrors!). Well, if you were an Oracle Designer user and […]

LISTAGG to a CLOB, avoid 4000 chr limit

Thanks to twitter I found this post by Carsten Czarski on LISTAGG and CLOBS that helped my with the 4000 character limit with LISTAGG(), found when building JSON strings.
ORA-01489: result of string concatenation is too long

I follow a few bi-language blogs but I do wonder if English speakers may find this post when googling the issue. For me it's on page 1 when googling "listagg clob", but I knew what keyword to search (more...)

1 Uncool Thing about the COMPARE_SYNC Package

It only works in version 12 :( That’s right, I didn’t test in previous versions and there was a bug. Please refer to the COMPARE_SYNC post for the new, improved version. Here is what I changed: The name is now COMPARE_SYNC. I don’t know what got into me to put those four meaningless letters in front. The […]

APEX: Active Tabs Based on Page Groups

Recently someone asked me: "How did you do that? When I include an APEX page in a Page Group, the correct tab is automatically highlighted"
When I setup an application, I usually use Dimitri Gielis' method, so instead of using "real tabs", I use a List and display that list as Tabs.
For each of the "Tabs", I also create Page Groups, just to keep things organized.
Each of the List Entries will have a (more...)

Datensätze generieren

Das Thema ist nicht neu, aber bei der Gestaltung komplexerer SQL-Logik immer wieder von Interesse: wie generiere ich effizient eine größere Menge von Datensätzen mit einer eindeutigen id? Dazu hat Natalka Roshak eine kleine Serie gestartet, die bislang zwei Artikel umfasst, und in der zunächst vier verschiedene Verfahren vorgestellt werden:

-- rekursive Variante mit connect by level
select level id
from dual
-- rekursive Variante mit subquery factoring
connect by level <= 10;


Comparing NULLable Values

If a column or expression may be NULL, it is a pain to compare it to something else. Why? Because comparisons involving a NULL do not result in TRUE or FALSE: they result in NULL. I use the DECODE function to work around this problem: here's why - and how.

OTN Yathra 2015 just got over!!

Quite well said – Investment in knowledge is the gives you the best returns. It was a great fun last week to be the speaker at OTN Yathra 2015, organized by All India Oracle Users Group (AIOUG). The OTN tour covered seven cities and I was the part of it at three cities i.e. Hyderabad, Bangalore … Continue reading

Database design resources: My reading list

Following the database design championship playoff over on the PL/SQL Challenge, one player asked:

“Could you please advise me some resources (boooks, courses) so that I can improve?”

Of course I can! This is what I love to hear – people looking for resources they can use to increase their skills. This is information I’m sure others will benefit from, so here goes:

select materials
from   my_readings
where  topic = 'Database design';


SQL Developer: Viewing Trace Files

Just a quick plug for looking at raw sql trace files via SQL Developer.

There is a nice Tree View:

Which can be expanded:

Also summary view of statistics, filterable:

And a list view, filterable and orderable:


Some sort of right click summary for binds/waits might be a nice addition.

Real time sql monitoring – bulk bound statement

Moving through some observations of an ongoing investigation tackling the easiest ones first.

Previously I observed the slow execution of a recursive delete of statistics history but coming not from MMON but from a number of application processes which should have only been calculating stats for their own partitions.

Statement was sql id 9v9n97qj8z1dg:

delete /*+ dynamic_sampling(4) */
from sys.wri$_optstat_histhead_history
where savtime < :1
and rownum <= NVL(:2, rownum);

From the real time sql (more...)

NVL und Count Stopkey

Ein kleiner - aber wichtiger - Hinweis vom Dom Brooks: für Queries mit einer rownum-Einschränkung ist normalerweise die COUNT STOPKEY Optimierung im Spiel, die die Ausführung der Operation abbricht, wenn die gewünschte Satzanzahl erreicht ist. Wenn man allerdings eine solche Einschränkung mit einer NVL-Funktion kombiniert, also etwa:
where  rownum <= nvl(:rn,rownum)
dann wird die Optimierung deaktiviert und die Ausführung bis zum bitteren Ende fortgesetzt.

The German ADF-Community-Book was released today

The German ADF- (and Forms-) Community released their first book.

The "ADF book" is a compilation of German lectures, articles and workshop tutorials in Oracle ADF (some of the contributions are in English!). The authors are members of the German ADF community. The time frame covers the years 2010 to 2014. The project "ADF book" was implemented by a team of staff from partner companies and Oracle.

40 authors wrote 70 contributions on 1400 (more...)


Yesterday I mentioned issues with a recursive delete operation on statistics history.

This is a quick illustration of the last points I made on that post regarding the lack of a COUNT STOPKEY optimisation because of the use of NVL.

COUNT STOPKEY is an optimisation which allows processing to stop once the target number of rows has been reached.

For example:

create table t1 as select * from dba_objects;

alter session set statistics_level = all;


Meet me in Austin?

Late breaking news (aka I forgot to post this earlier)! I will be speaking at the first meeting of the Austin Oracle Users Group for 2015. It will be this coming Friday February 27, 2015 starting at 11:00 AM. I will give an intro talk on Oracle SQL Developer Data Modeler (the FREE data modeling […]

Understanding vs Resolution – Statistics History Cleanup

Today I helped resolve a problem quickly but to the detriment of my understanding of exactly what was going on and why.

And as part of the quicker resolution, I had to destroy the evidence which would have helped understand better.

So… now need to go back and figure it out if I have time to model it properly, etc.

Here’s what little I know so far.

What happened was that there were a number (more...)

Limit für die Verwendung von “colored SQL” im AWR

Das Automatic Workload Repository (AWR) gehört meiner Meinung nach zu den großartigsten Errungenschaften der jüngeren (oder auch nicht mehr ganz so jüngeren) Oracle-Geschichte, da es eine Historie von Abfragen und ihrer Performance bereitstellt. Allerdings ist diese Historie nicht vollständig, da sie auf Sampling basiert - es kann also vorkommen, dass interessante Queries nicht erfasst werden. Um dieses Problem zu lösen, wurde in 11g die Routine dbms_workload_repository.add_colored_sql eingeführt, die es ermöglicht Abfragen "einzufärben", was nichts anderes (more...)

Alexandria PL/SQL Utility Library moved to GitHub

The PL/SQL Utility Library, codenamed "Alexandria", now has a new home at GitHub. This will make it easier to collaborate on the project. If you want to contribute, just fork and submit a pull request.

The liibrary contains around 50 PL/SQL packages as well as a few types. There are no table dependencies, which reflects the general-purpose nature of the utilities. Jeffrey Kemp has a great guided tour of the library which highlights some of (more...)

The Database Design Quiz in Numbers: 2014 Review

The results of the first ever database design championship playoff were announced today. Huge congratulations to Sean Molloy, Pavel Zeman and Justin Cave for taking the top three spots. Also thanks to everyone else who’s taken part in the quiz, answering questions, adding to the discusions and pointing out my mistakes ;)

With this in mind here’s a some of the facts and figures from 2014’s database design quizzes, along with related trivia:

-- How  (more...)

Introducing the Official LinkedIn APEX Group

Once upon a time I had a laugh on facebook when someone posted an image showing multiple groups dedicated to stopping duplicate groups, oh the irony.

Recently I've been trying to share my blog posts via LinkedIn but I'm always unsure which of the seven APEX groups I'm a member of I should post to.

It turns out only the SIG groups are owned by those involved with the APEX development team, namely David Peake (more...)