Author Archives

How not to do it…

Two years ago at Oracle Open World, I delivered a "worst practices" talk - how not to do stuff.  I used the word "probably" a lot, for example "you probably don’t need to use bind variables" (there were slides stuck in this slide deck throughout that said ‘hey, these are all the opposite of reality - just in case you are reading this - they are not true!’).

In the same genre - we have "Top Ways How NOT To Scale Your Data Warehouse".  This comes from the Structured Data blog penned by Greg Rahn - that article as well as the others make for some really good reads.

While I’m pumping that blog - another one to definitely look at is Richard Foote’s blog.  He’s been undertaking the destruction of many a myth regarding indexing (like ‘indexes like large blocks’, ‘rebuild when height hits N’, ‘Separate tables from indexes for performance’ and the like).  Very easy to read, very enjoyable to read.

If you use multiple computers like I do - you might be interested in http://www.instapaper.com/ - find something you like, but don’t have time to read right now - save it for later.  Very nice.

The ‘write’ stuff…

Not long ago - I wrote about some frustrations with the state of software ‘development’.  This morning I read an article written not too long ago "They Write the Right Stuff".  I liked it a lot.  Maybe not practical or reasonable for every piece of software (but then again, why not?) - but definitely sound techniques and processes for everyone.

The sections are

  • The product is only as good as the plan for the product.  Ah, they are talking specifications, communication, documentation…
  • The best teamwork is a healthy rivalry.  Indeed!  I’ve said before the best was to test your ability to recover in a DBA team would be to set up two teams - one is responsible for damaging a test database in any way they want to.  The other team is responsible for recovering from that catastrophe.  Next week - switch sides.  Not only fun but very enlightening (when I poll audiences, less than 5%, way less, have done a recovery in the last six months - could it be they might not be able to today if needed?).
  • The database is the software baseNow, they did not mean the database is the center of the application itself (I would say something like that) but rather the history, change control, reason for all change is.  The history, the legacy of the code is as important as the plan for the product.  You need to understand why things were done the way they were - in order to safely change it later.
  • Don’t just fix the mistakes - fix whatever permitted the mistake in the first place.  My favorite one!  How many times will I have to hear in my life "we have to do X, but you cannot tell us to use method Y to do it - Y cannot be done".  I get that all of the time - tell me how to make it go faster, but don’t look at or mention touching the application.  The mistakes are typically to be found there - in the application (typically means 99.99999999999999999% give or take a small amount).

 

As an aside, anyone that knows me, knows my mantra - written many times:

  • You should do it in a single SQL statement if at all possible.
  • If you cannot do it in a single SQL Statement, then do it in PL/SQL (as little PL/SQL as possible!).
  • If you cannot do it in PL/SQL, try a Java Stored Procedure.  The number of times this is necessary is extremely rare today with Oracle9i and above.
  • If you cannot do it in Java, do it in a C external procedure.  This is most frequently the approach when raw speed, or the use of a 3rd party API written in C is needed.
  • If you cannot do it in a C external routine, you might want to seriously think about why it is you need to do it…

 

Therefore - I just loved this Oracle-WTF.  And you know what - it pairs up with the "write stuff" article nicely.  I’ll bet you that that original stored procedure was not planned (no specs), peer reviewed (no health rivalry), change managed as it was tweaked over time, and until now - never "fixed".  Can you imagine how long it took to reverse engineer that into a single SQL statement (I’d guess a minimum of an hour - and likely more).  An hour well spent, but I know personally the frustration of that person for that hour - cursing every developer that touched the code before them.

And I cannot tell you how much I hate code like this:

    BEGIN        v_temp_runs := 0;        SELECT COUNT(*)        INTO   v_temp_runs        FROM   dual        WHERE  EXISTS               ( SELECT *                 FROM   temp_runs );    END;

    IF v_temp_runs > 0 THEN
 

Why count something and do something else if there was something to be counted?  JUST DO IT, if there is nothing there - SO WHAT?

At least the original code did not end in "when others then null;" - there is that.

UKOUG Call for papers…

The UKOUG call for papers has been announced.  This is an event I’ve personally attended every year now since 2003.  I’ve met and made some very good friends at this conference.  I strongly recommend it as a technical forum.  It is a large but not overwhelming large event - with lots of technical content (and a bit of fun as well).

I’ve written in the past about participating in the user community - this is the perfect chance.  Everyone has something useful to contribute - everyone does. 

So, get on the OTHER SIDE of the podium.  Yes, it can be scary, but it is definitely worth the fear factor long term.

Looking for ideas…

I use a couple of venues to generate new material, new talking material every year.  Hotsos symposium has always been one, Oracle University Seminars have been another.  Oracle OpenWorld is definitely one as well.

Well, believe it or not, it is time for me to submit my abstract for Oracle OpenWorld already - even though it is not until September.  So, it is time to come up with yet another topic.  I’ve been known to do a “top ten” style presentation for a while at OpenWorld - the last few years have been top tens on 9i Release 2, 10g Releases 1 and 2 and most recently - 11g Release 1.  Intermixed with that was a database ‘worst practices’ presentation as well.

So, now - I’m looking for some fresh ideas.  A topic that can be well covered in an hour and would have broad general appeal.  In reality - if I get a couple of good ideas, I’ll probably generate the material for all of them but just pick one (maybe two) for presentation at OpenWorld. 

So, I invite you to submit an idea - doesn’t have to be fully fleshed out - just a concept, something you would find useful at a venue such as OpenWorld (or a presentation to a user group - as this is where this material will be used time and time again…)

Thanks in advance for any ideas!

It has been a while…

It has been a while since I’ve last posted.  Was waiting for inspiration I guess.  I’ll be a bit more regular in writing in the future, just hit a dry spell for a bit.

I received inspiration this morning in the form of a question on asktom.  Nothing like a good rant to get going again… I really fear for our "profession" sometimes.  I’m not even really sure some days it is a profession - because if it were a profession - that would imply, well, qualifications. 

Ok, so here it is - the question du jour:

i need your help on how to write applications for mobile banking usin sql, pl/sql or any other product availabe, i am a applications developer and a junior DBA just starting and it is one of the targets i heve to meet in my job,the deadline is getting closer.
your help will be appreciated.
thank u tom for given me an oppurtunity to ask this question.
will be expecting ur reply

Ok, here we are - I want an education on how to write applications for mobile banking.  Now, "mobile banking"  isn’t really something you want someone to cut their teeth on is it?  I mean - I really really want my bank to use developers that already sort of know how to build a transaction processing system.  Also, what sort of financial institution would use a single "junior DBA and part time application developer" as their development team?

"The deadline is getting closer" - and they do not know how to develop a database application.  That is something they should have possibly considered before accepting the job.

The IM speak of "ur" and "u" were just the icing on the cake.

Cary Millsap just wrote about something similar.  An application interface in the UK that offered him the first 2,000 qualifying bus trips he could take from one airport to another.  What were they thinking as they "designed" this - what were the developers thinking when they said "yeah, we’ll make this user interface to find a bus easy - we’ll be super efficient and terminate the search after 2,000 hits".  2,000 hits.  Seems like anything more than 10 would be overkill.

Another recent thread on asktom got under my skin as well.  A reader wrote in part:

My problem is that I have critical servers (24×7 with a 99.999% SLA)

I suggested, perhaps, that implementing some HA features would be useful in helping them get to 99.999% (a hard task indeed).  They write back:

I think that my customer don’t have budget to HA.

The only thing I can think to say back to that is

So, stop saying "I have to have 5 9’s" if you are going to say "don’t have budget" - they are oxymoronic.

I really don’t think that people understand what they are signing up for some days.  "teach me mobile banking - I have a deadline".  "Give me 5 9’s, without any money".  Five nines takes a lot of up front design work, a lot of infrastructure, a lot of effort - it doesn’t just "happen"

I am not generally in favor of "certification", but I seriously think we have a real problem here.  If just anyone is allowed to put themselves up as a developer - everyone will.  Regardless of ability, training, whatever.  Doctors and Lawyers and many other professionals have to meet some basic minimums in that area - perhaps the people that write the stuff that manages our money, our health, our airplanes, heck - virtually every aspect of our lives in many cases - should have to do the same. 

 

Updated: I think this link is somewhat relevant…  Long but relevant…

Hah, they didn’t even mention “bind variable”

But, we all know that is the true cause of the problem… The lack of use of bind variables - making special characters in names do nasty things like: (this is a quote)

… apostrophe is often mistaken for a piece of computer code, corrupting the system. …

Ah, yes, the nasty apostrophe, capable of corrupting entire systems.

It is sloppy programming (they got that right).  Lack of binds is a co-winner of first place "bad things to do" right along side "when others then null".

I still wish….

  • when others would be removed from plsql
  • triggers would be deprecated and removed
  • autonomous transactions would start just raising errors
  • literals in sql would raise an error

All of those bullets are hyperbole, but they make a point.  When I see "when others" in code, it is more often used wrong (in the order of 1000 to 1).  When I see a trigger developed to "enforce integrity" - it is almost always wrong.  The way people use autonomous transactions - almost always WRONG.  Literals in SQL - usually wrong (but not always, but here I would err on the side of caution - outlaw literals and let bind peeking put them back in later…)

I know, I’ve said this before.

You know, I’ll say it again.

Because I see the same four mistakes every day.  Every. Single. Day.  Especially the "when others" and lack of binds.  Followed by triggers.  Fortunately, most programmers never read to the autonomous transaction chapter…

YAB…

Yet another blog - a friend of mine, Tyler Muth, has been blogging for a while.  He concentrates mostly things PL/SQL, APEX and developer related. 

Maybe I should get him to format my entries from time to time - his look really nice.  Hope you find it useful.

Why the command line rocks…

because when you own it, you own the world.  You can literally do anything you want (given you have that privilege of course)…

Check this out.  Neat eh.

Control the command line and nothing will ever control you.  You have to understand something before you can do that stuff.

Besides, ASCII art is universal… (ctl-f for "A standard confirm")

 

ops$tkyte%ORA10GR2> CREATE TABLE hash_example  2  ( hash_key_column   date,  3    data              varchar2(20)  4  )  5  PARTITION BY HASH (hash_key_column)  6  ( partition part_1 ,  7    partition part_2 ,  8    partition part_3 ,  9    partition part_4 10  ) 11  /

Table created.

ops$tkyte%ORA10GR2> insert into hash_example  2  select sysdate+rownum, 'x'  3    from all_objects  4   where rownum <= 10000;

10000 rows created.

ops$tkyte%ORA10GR2>ops$tkyte%ORA10GR2> select pname, cnt,  2         substr( rpad('*',30*round( cnt/max(cnt)over(),2),'*'),1,30) hg  3    from  4  (  5  select uo.subobject_name pname, count(*) cnt  6    from user_objects uo, hash_example he  7   where uo.data_object_id = dbms_rowid.rowid_object(he.rowid)  8   group by uo.subobject_name  9  ) 10  order by pname 11  /

PNAME                                 CNT HG------------------------------ ---------- ------------------------------PART_1                               2398 ***************************PART_2                               2466 ****************************PART_3                               2563 ******************************PART_4                               2573 ******************************

The word pathetic never sounded so good…

A while ago, a friend - Alberto Dell’Era - sent me a link to some youtube videos.

Videos on SQL.

It is SQL worst practices - presented in 20 minutes by Stephane Faroult.  To hear "pathetic performance" with the accent just made me laugh.

Note to all developers:

watch these - they are good, they are correct (they are ironic, anti-patterns, don’t do them - do the opposite). 

Some people have said they could not see the embedded videos (probably using a news aggregator/reader - not the source entry itself).  Here are the links, embedded videos follow:

Part 1: http://www.youtube.com/watch?v=40Lnoyv-sXg
Part 2: http://www.youtube.com/watch?v=GbZgnAINjUw
Part 3: http://www.youtube.com/watch?v=y70FmugnhPU

 

 

it is neat to hear words I’ve said time and time and time again, said by someone else :)

Hear hear…

I give a presentation on "worst practices" from time to time

 

s1

 

One of the many sections in there regards source code control/configuration management (remember, this is a worst practice talk, not a best practice - so the slides are meant to be ironic, the opposite of what is true)

s2

In there I talk about how many people don’t seem to consider their "database schema" (including code for goodness sake!) to be something that you put under source code control.  Nope, you just let everyone in there and let them make changes - in the database directly. 

s3

They consider database code to be less than code - not worthy of being under any sort of change management.  That is why I liked this blog entry I read this morning.

They got it right - dead on.

Think about it…