div.b-mobile {display:none;}

Tuesday, October 31, 2006

This site owes me a new monitor!

Because I destroyed one spraying coffee all over it when I read this posting.

I laughed out loud at it at first, and then got really sad.  Sad - because it is so very very true.  Silly stuff like that is done every day, all of the time, over and over.

At Oracle Open World this year, I did a tongue in cheek talk on "Database Worst Practices".  One of the slides was simply:


Probably... Indeed.  I quit my first job after six years because of this "let us reinvent everything" syndrome.  I was the technical lead and had people working on tasks like:

  • Implement two phase commit generically
  • Write a database independent stored procedure language compiler/runtime engine
  • Write a SQL 89 query parser
  • Develop a distributed query optimizer

It was nuts - here I was reading the Oracle 7.0 documentation which described all of the above.  We had already purchased the technology - but we had to be "database independent".  That made me walk.  Interesting side note: I didn't walk straight to Oracle, I actually had another job all lined up, it was pure serendipity that brought me to Oracle by accident in August 1993.

I followed that slide up with the reasons you "probably" should reinvent the wheel:



Using builtin functionality will not demonstrate to your manager how good of a coder you are!  So true isn't it?

The builtin stuff only does 99.99% of what you specified, it is deficient, you have to code it yourself.

Absolutely - so true (not).

But it is done all of the time, every day, constantly.  And when the developer (who is only 1/4th the way through the implementation) is told "hey, it already does that" - do they stop?  No, not a chance - for you see, you have the time already invested, it would be such a waste to just discard it wouldn't it?

Drives me nuts...



Anonymous Anonymous said....

"it was pure serendipity that brought me to Oracle by accident in August 1993."

- So what was that accident?

Tue Oct 31, 03:18:00 PM EST  

Blogger Basil Faulty said....

Unless the existing implementation is not working as advertised and the tech support is not helping.
Yes, I mean Workspace Manager.

Tue Oct 31, 03:40:00 PM EST  

Blogger Joel Garry said....

But didn't those six years of doing it yourself help you to understand what Oracle was, or should have been, doing?

Wasn't there any time when you went "Why does Oracle do it this way? It seemed so obvious to do it my way when I did it?"

word: dnsdwks

Tue Oct 31, 03:59:00 PM EST  

Blogger David Aldridge said....

I come across that method for deliberately serialising processes quite a lot. Locking or updating a row in a table must be the generic way of doing things I suppose, but if you don't want a generic solution then it has always seemed to me that DBMS_LOCK is the more proper way of achieving that in Oracle. (Serialising processes, not implementing transactions).

Tue Oct 31, 04:09:00 PM EST  

Blogger Thomas Kyte said....

But didn't those six years of doing it yourself help you to understand what Oracle was, or should have been, doing?

Nope, it wasn't the entire six years, just the last project (the last 1.5 years).

It was

book #4
there that was responsible for understanding how it should work.

Tue Oct 31, 04:12:00 PM EST  

Anonymous Kevin Closson said....


Could you please give us your opinion about the Java engine inside the Oracle Kernel? I think the wave of re-writes people did from PL/SQL to Java might not have happened if you were giving this (really good) presention right after 8i shipped. Thoughts ?

Tue Oct 31, 05:03:00 PM EST  

Blogger Noons said....

What is even more scary is the string of comments that follow that post in dailywtf!

There are even some folks trying to argue it is the right thing to do, or "how to do it right with (whatever)".

Unbelievable. But so darn true. I've been hitting this same mindset and warning about it since 1999 when I first came into direct contact with the new wave of "programmers". Mostly in the j2ee arena, but not just there: it's much more pervasive.

Folks here in Australia sometimes reckon I'm being too harsh on these practices. Sorry, no: they MUST be stamped out of IT! No excuses, no exceptions.

Tue Oct 31, 05:35:00 PM EST  

Anonymous Anonymous said....


What did you start out doing at Oracle? Were you ever a DBA or are you primarily a developer?

Have you ever worked on the actual Oracle database?

Tue Oct 31, 09:44:00 PM EST  

Blogger Arthi! said....

Hi Tom,

Can I please have the permission to share the worst practises PPT with my work-group?


Wed Nov 01, 01:19:00 AM EST  

Blogger Phil said....

I choked on my dinner when I read the Daily WTF last night. Didn't figure I was alone.

Ignorance of the law is not a valid defense in court. Why is it, then, that so many developers get away with remaining ignorant of their platform features? My guess: too many contractors billing hourly.

Wed Nov 01, 07:35:00 AM EST  

Anonymous Leo Mannhart said....

it hast to be database independent

yes, I know this; thats when you (have to) rewrite your pl/sql generator (for generating views for example) as a java program.

It is stupidity on stilts (IMHO).

Wed Nov 01, 07:51:00 AM EST  

Blogger Thomas Kyte said....

Could you please give us your opinion about the Java engine inside the Oracle Kernel?

I've written in the past that you would use java in the database if and when and only if PL/SQL could not reasonably perform the operation. Eg: if you REALLY needed to list the files in a directory (in order to issue an alter table to point an external table to the new file for example) a java stored procedure would be called for.

See the mantra :)

What did you start out doing at Oracle?

I started as a Sales Consultant, I stuck out like a sore thumb however, as I was a transplanted developer. Speaking in public scared me to death :) Things change. I was a developer/DBA in my prior life.

I've contributed plsql bits to the database, but never worked on the C code that is the database (and have no desire to)

Can I please have the permission to share the worst practises PPT with my work-group?


Wed Nov 01, 08:18:00 AM EST  

Anonymous Anonymous said....


Why don't you want to code the Oracle database? I would think that would be very challenging.

What kind of people does Oracle recruit to code the database? Are alot of your senior people PhDs?
Do members of your development spend alot of time reading the academic research into databases to get new ideas?

We don't hear too much from people who work on the database. Only a small number of them are visible to the public. I think it would be really interesting to have some form of blog on the Oracle website from guys working on the software discussing how they came up with ideas for this and that feature.

Wed Nov 01, 08:56:00 AM EST  

Blogger Thomas Kyte said....

Why don't you want to code the Oracle database? I would think that would be very challenging.

it is a huge piece of code, written by many people, that takes a long time to get your head around.

That isn't what I do.

You get to meet a lot of them at Oracle Open World actually. There was about 700 people from server technology there this year alone.

Wed Nov 01, 09:05:00 AM EST  

Anonymous Anonymous said....

How many developers work on the 11G database at one time?

Are they all in california or do you have people all over the place?

Wed Nov 01, 01:18:00 PM EST  

Blogger Thomas Kyte said....

How many developers work on the 11G database at one time?

I cannot be more precise than "a lot" and it is a 24x7 worldwide sort of thing.

Wed Nov 01, 04:14:00 PM EST  

Anonymous Robert said....

Tom, did you ever mentioned how you got to Oracle and what were your first job responsibilities ? I'd be interested to know

Wed Nov 01, 05:37:00 PM EST  

Anonymous JulesLt said....

The one that really winds me up at work - people implementing manual polling mechanisms rather than using queues. Even after I've said 'use a queue'. You'd think the fact they can treat it as JMS and not have to deal with JDBC at all would be a plus point.

2nd best : Querying a large data set into objects and then looping over the set to filter them into a second set because you don't know how to do it in SQL.

3rd best : 'Databases are slow' or something to that effect. A myth that presumably comes out of 'making a call to the database is slow'.

4. 'Feature X doesn't work'. In 1997. So we will never ever use it.

5. Let's store this bit of data in an XML file 'to save going to the database'. Then let's decide to query a value from hundreds of these XML files. Why is the program going slow? Why is it taking time to access even one file - hmm, because you've got tens of thousands of files in one directory and your file system isn't indexed so you're getting an n/2 search (probably worse if the bias is to recent files)? But we all know that storing data in flat files is faster than a database!

And yes, I've seen the manual locking thing too (which came out of the era when we had some hot OO designers who were very insistent that a database is basically a clever file storage aka object persistence mechanism. You definitely don't want to use anything like integrity constraints. What you want to do is write an integrity suite to check the data integrity as a batch job).

Oh, and I can't forget the fact that J2EE developers went with JDBC rather than a SQL-J style syntax (I can understand the reasons - i.e. portability - but the end result is code is still non-portable, the issues are just hidden in text strings. I'm sure the other approach could have been explored - i.e. standardising a spec for an interface the Java compiler could use to validate SQL).

Yes, let's make a huge deal out of the type safety of our language, then make sure that large sections of our apps are uncompilable (JDBC, JSP pages, the masses of XML config files used - because you wouldn't want to store config on a database).

(I had the 'bind variable' discussion a couple of months back too, which our Java friend tried to tell me sounded like a bug in Oracle . . .).

And you know what, it's still way less safe or productive a language than ADA - let alone PL/SQL's anchored type declaration. (The fact that Java developers are excited about Hibernate says it all).

But that's another rant - the one about how low-level languages 'win', because they get the ideological backing that higher level - aka business level - languages don't. Even when 95% of the time you're shuffling records around, not doing socket based comms. Also Java had the support of C++ developers while C++ had the support of C developers in the way that Smalltalk never did.

Wed Nov 01, 08:40:00 PM EST  

Blogger Niall said....

rereadin those slides makes me wonder why you didn't include

"You know that you will make a better, tighter, leaner job of it than Oracle did - their code is so bloated Man"

for the people who believe that not only should they reinvent a feature that's been around for years, but that they'll make a better job of it. in 2 months.

Wed Nov 01, 08:48:00 PM EST  

Blogger Thomas Kyte said....

JulesLt said...

Dude, I'd love to buy you a beer. I can so so so so relate.

You just listed my "top 5 (no make that six) things done wrong" talk.

Seriously, if you see me in a country near you - let me know :)

Wed Nov 01, 08:53:00 PM EST  

Blogger ruff around the edges said....

"Using builtin functionality will not demonstrate to your manager how good of a coder you are! So true isn't it?"

I assume you meant that as a joke. However it just might clue the manager in that
(1) the coder truly cannot compete with the library authors he intends to replace. Libraries (good ones anyway) tend to have a ridiculous number of tests to prove that all the edge cases are handled and that the thing generally works as advertised. OR
(2) the coder does not actually know the technologies listed on his resume. Done right, that could be a career altering move.

That said, I have encountered cases where a "rewrite" of existing vendor supplied code was actually necessary. But those were instances of silly bugs in poorly tested embedded systems.

Regarding juleslt's comment about type safety and uncompilable systems... That is a solvable problem, people just don't want to take the time to deal with it. XML config files should be validated against schemas (to handle the simple structural stuff) and have test routines to verify that the data actually makes sense. Java files with JDBC and SQL in string constants? Move the selects into views or functions, the updates into procedures, and all of it into packages -- then let the DBMS compile it. As for JSP pages, that's why we hire testers. < wicked grin >

I'm enjoying your blog and pictures.

Thu Nov 02, 12:37:00 AM EST  

Anonymous Leo Mannhart said....

ruff around the edges: Java files with JDBC and SQL in string constants? Move the selects into views or functions, the updates into procedures, and all of it into packages -- then let the DBMS compile it.

Are you kidding? You just violated rule #6 "you have to be database independent" and also forgot point #3 (from JulesLt): "databases are slow" while Java is a lot faster (than anything else).


Thu Nov 02, 03:10:00 AM EST  

Anonymous Anonymous said....

I take strong exception to the snide remarks made about contractors making all the mistakes in the Oracle world. I have seen these remarks many times but never said anything in defense. Upfront, I would like to say that I am a contractor and I bill hourly.

For the last 5 out of 7 years, I worked as a contractor for one of the top software development consultancy firms in US. They would hire JAVA/VB/ASP developers and then expect them to write top quality SQL, PL/SQL code. The contractors were given n hours to write a stored procedure and in those n hours, the business requirements changed more than once. Most of the times, the business requirement changes were conveyed to the contractors after the code was finalized and then they were under the gun to get the code changed and tested quickly. The contractors worked 12-14 hours days+weekends without getting paid for it. There was no code review policy either by peers or by anyone. If the code returns the desired results, just send it into production. Tuning can be done later. This was all the attitude of project management staff who were employees of that company and got paid big money. If a contractor did not comply, he/she was fired promptly. As a result, the code was functional but could not be called quality code. If I post code snippets, everyone will beat their heads against the wall. I do not blame any contractor for writing such poor code. They did not have the skills to do it in the first place; they did whatever best was possible in the time frame allocated to them by the project management. They were not given any time for tuning the code no code review policy was in place.

Before blaming bad code on contractors, ask the following questions:
a) Who hired the contractors? Did he make sure that the contractors have the right skill sets? Is the project manager expecting application design from a contractor hired as a coder?
b) Did anyone do a code review? What are the organization's coding/code review standards? Is there any time allocated for performance tuning in the project plans?

For the last one year+, I am working as a contractor in a place where, if the contractors were to leave, the entire operation would come to a standstill within a week.

Just remember, contractors always work for someone else and are governed by how that organization works. Most times, they bring more to the table than the regular employees since a contractor has his professional reputation at stake. An employee performing badly will have a poor review. He may not get a raise. A contractor will not get the next project if he gets a bad reference from his project managers.

Thu Nov 02, 09:59:00 AM EST  

Blogger Phil said....

Anonymous Contractor,

I too have worked for that consulting company. "Too many contractors billing hourly" is a very different statement from "Code is bad because contractors are greedy people."

Contractors mean that the Company wants to get results ASAP, because contractors are costing them money. This generally means rushed and incomplete requirements, which (as you say) leads to bad code.

Contractors also mean that the Company generally doesn't have budget to develop their own staff's skills through training and general development. In order to "keep current and on top of things" you probably need to spend 10-20% of your time doing personal skills development. Having no budget means that you might be able to go to a one week course every other year.

Honestly, bad code is ultimately the fault of simple-minded management. Good design yields good code; poor design *ALWAYS* leads to bad code and a search for the quick fix.

Poor design happens because 1) there isn't enough time, and/or 2) people doing the design don't have the necessary skills (both technical and business) to tease out requirements and come up with an architecture/design that will meet the requirements.

Fri Nov 03, 09:40:00 AM EST  

Blogger Vinod Joshi said....

how much time does it take to you to write one page of a book. I am asking because I have read oracle books from different authors but the way you explain things makes people feel Oh that was a simple enough concept? Why did we not think that way. It simply amazing

Wed Nov 08, 03:25:00 PM EST  

Blogger Thomas Kyte said....

It would be hard to put a precise number on it - some pages are really fast, others not so.

I've had times when I can do 30 pages (in word) in 8-12 hours, edit them (after the reviewers rip them up) in 8-12 hours.

I've had other times when I need 3 or 4 days to get that 30 pages, and longer to rewrite them (this is rare, case 1 is more like it)

So, let's say "about 1 hour"

Wed Nov 08, 06:03:00 PM EST  

Blogger Joel Garry said....

I used to budget about one hour per page (after all info was gathered) for writing up things in college - on an electric typewriter in the '70s.

There must be some profound productivity insight there.

Tue Dec 12, 04:39:00 PM EST  

Anonymous Chirayu said....

Hey Tom,

link is not working.. can you please fix it.

Fri Jul 09, 08:41:00 PM EDT  

Blogger Thomas Kyte said....


will work

Sat Jul 10, 12:54:00 PM EDT  


<< Home