Skip to main content

PL/SQL Programming Joke #3: Need to make my code compile faster!


As my 25th winter in Chicago approaches (and after the 2016 elections),, I attempt to cheer myself up with jokes. Programmer jokes.

Jokes that largely have to do with being too lazy to verify assumptions or prove claims before making decisions that turn out to be really bad decision. 

Here's the most recent "joke" I heard from a developer, via an email back in July:
We just encountered a PL/SQL performance problem after migrating a database from 10g to 11g and I tought it might interest you. I isolated the problem using  the 10046 traces and DBMS_PROFILER. So I was able to reproduce the problem with a very simple PL/SQL testcase, but I cannot explain it.
He then pasted in 439 lines of code and output. So this is the "very simple" testcase? It might be, but still I wrote back:

"It may be simple, but it's long and I'd appreciate it if you would summarize for me what you believe you have discovered."

This way, at least, I didn't have to feel the least bit obligated to tangle with his problem until he replied.

But his response was even better and more entertaining than I'd hoped:
I just found out the cause of the strange behavior...Somebody had set the PLSQL_OPTIMIZE_LEVEL to 1 instead of 2 at the database level so that a massive recompilation of all packages would go faster.
When the optimization was set back to 2, the performance problem he noticed earlier disappeared. Hurray!

So now let's go back and parse that paragraph:

"Somebody had set" the optimization level - I sure hope that somebody else knows exactly who that original somebody is. You'd like to think that there aren't too many people with the authority to change the default optimization level on a database instance.

"…so that a massive recompilation of all packages would go faster."

Ah, that's just too delicious! Again, an element of truth that goes a loooong way towards mucking up application performance.

It is true that the higher you set the PL/SQL optimization level, it takes longer for your code to compile, because the compiler is doing more work analyzing and applying transformations to your code to improve runtime performance.

Hey, let's shrink that paragraph down to its essence:
Spend more time compiling your code so that code runs faster for your users.
Sounds like an excellent tradeoff. We wait a little longer for code to compile (and would we even notice the difference? Unlikely.) and in return our users are happier.

Not for that DBA, though. Maybe he had a hot lunch date or had signed up for one of Tom Kyte's amazingly popular webinars and trainings and that was about to begin. At which point he might learn about how important it is to keep that optimization at least at 2. 

Whatever the case, all he knew was that he needed to get that code complied fast.

I just hope it wasn't on a production instance.

Know Any Good "Jokes"?

I bet you've run into all sorts of hilariously truthy stories of developers or DBAs doing the most absurd things for the only slightly less absurd reasons. Please share them with me, either via comment below or by sending an email to steven dot feuerstein at oracle.com. 

In the meantime, don't forget to set the optimization level to 1. Or maybe 0. That way your code will compile faster. 

Giving you less time for that extra cup of coffee. Which is probably a good thing.

That was a joke, OK? Optimization level at 2 or higher, please! 


Originally published in ODTUG's Confessions of a Quick and Dirty Programmer series

Comments

Popular posts from this blog

Quick Guide to User-Defined Types in Oracle PL/SQL

A Twitter follower recently asked for more information on user-defined types in the PL/SQL language, and I figured the best way to answer is to offer up this blog post. PL/SQL is a strongly-typed language . Before you can work with a variable or constant, it must be declared with a type (yes, PL/SQL also supports lots of implicit conversions from one type to another, but still, everything must be declared with a type). PL/SQL offers a wide array of pre-defined data types , both in the language natively (such as VARCHAR2, PLS_INTEGER, BOOLEAN, etc.) and in a variety of supplied packages (e.g., the NUMBER_TABLE collection type in the DBMS_SQL package). Data types in PL/SQL can be scalars, such as strings and numbers, or composite (consisting of one or more scalars), such as record types, collection types and object types. You can't really declare your own "user-defined" scalars, though you can define subtypes  from those scalars, which can be very helpful from the p

The differences between deterministic and result cache features

 EVERY once in a while, a developer gets in touch with a question like this: I am confused about the exact difference between deterministic and result_cache. Do they have different application use cases? I have used deterministic feature in many functions which retrieve data from some lookup tables. Is it essential to replace these 'deterministic' key words with 'result_cache'?  So I thought I'd write a post about the differences between these two features. But first, let's make sure we all understand what it means for a function to be  deterministic. From Wikipedia : In computer science, a deterministic algorithm is an algorithm which, given a particular input, will always produce the same output, with the underlying machine always passing through the same sequence of states.  Another way of putting this is that a deterministic subprogram (procedure or function) has no side-effects. If you pass a certain set of arguments for the parameters, you will always get

My two favorite APEX 5 features: Regional Display Selector and Cards

We (the over-sized development team for the PL/SQL Challenge - myself and my son, Eli) have been busy creating a new website on top of the PLCH platform (tables and packages): The Oracle Dev Gym! In a few short months (and just a part time involvement by yours truly), we have leveraged Oracle Application Express 5 to create what I think is an elegant, easy-to-use site that our users will absolutely love.  We plan to initially make the Dev Gym available only for current users of PL/SQL Challenge, so we can get feedback from our loyal user base. We will make the necessary adjustments and then offer it for general availability later this year. Anyway, more on that as the date approaches (the date being June 27, the APEX Open Mic Night at Kscope16 , where I will present it to a packed room of APEX experts). What I want to talk about today are two features of APEX that are making me so happy these days: Regional Display Selector and Cards. Regional Display Sel