• (cs)

    Where is the Error'd for today? I thought it's posted before the text WTF.

  • Sir Davey (unregistered)

    Chris new that VARCHAR(100) was here to stay.

    I think this should read

    Chris knew that VARCHAR(100) was here to stay.

  • newt0311 (unregistered)

    Since when did correct data typing in the production database become optimizations???

  • (cs) in reply to newt0311
    newt0311:
    Since when did correct data typing in the production database become optimizations???

    Hm ... it is technically an optimization. SQL Server would definitely run faster when the conversion type load is taken off.

    Somehow, this sounds familiar ... I think my brain is blocking the memory ....

  • (cs) in reply to newt0311
    newt0311:
    Since when did correct data typing in the production database become optimizations???

    Good catch there. You've official identified the WTF. Congratulations.

  • sol (unregistered)
    int calc_0001 = ((width/height) - sin(width * height)) ^ 1337;

    Wonders why would I optimize this amazing one liner.. (*note I use this same calculation in 783 other location and portions of it 120,973,000 other locations)

    int width_height_ratio = width/height;//????
    int width_height_sinWaved = sin(width*height);//???
    int dif_width_height_ration_sinWaved =  (width_height_ratio - width_height_sinWaved); //????
    int wtf_modulas = dif_width_height_ration_sinWaved ^ 1337;///WTF
    

    of course I have no idea what your talking about... just don't cache anything and it will all be faster ;)

  • George Jansen (unregistered)

    Well, shucks, folks, the cure is simple. Install Oracle EE, and then you can use function-based indexes

    CREATE INDEX thetab$thecol on thetab(to_date(thecol, 'YYYY-MM-DD'));

    Slow under insert, expensive, baroque--an excellent match for the environment, don't you think?

  • (cs) in reply to newt0311
    newt0311:
    Since when did correct data typing in the production database become optimizations???

    This is just like building a car with square wheels, then calling the switch to circular wheels an optimization...

    I like the idea of having a database with nothing but varchar(100) values though. Very enterprisey.

  • (cs) in reply to George Jansen
    George Jansen:
    Well, shucks, folks, the cure is simple. Install Oracle EE, and then you can use function-based indexes

    CREATE INDEX thetab$thecol on thetab(to_date(thecol, 'YYYY-MM-DD'));

    Slow under insert, expensive, baroque--an excellent match for the environment, don't you think?

    This should also solve the wasted-space problem - Oracle handles varchar2 fields more space-efficient.

  • sol (unregistered)

    SELECT * FROM USER_TAB_COLUMNS WHERE DATA_TYPE = "VARCHAR2";

    NaN RETURNED after 90000.02345234562345645E minutes;

  • (cs) in reply to ammoQ
    ammoQ:
    This should also solve the wasted-space problem - Oracle handles varchar2 fields more space-efficient.
    If I were drinking coffee just now, I would have spit it all over my monitor :(
  • StressBomb (unregistered)

    While chiming in with the rest that proper DB design isn't optimization, the "don't optimize prematurely" tune is heard too often these days.

    The truth is, you have to think about proper architecture and optimization potential at every step. Most experienced developers know this, and this is what they mean by "optimize later", but the way they word it makes newcomers develop flawed architectures from the start, and then be stuck with poor consistency and performance forever.

    There's a huge difference between poor architecture and API that's unoptimizable at any later stage, and a proper development plan, which ALTHOUGH may include naive implementations for all underlying features, are opened to optimizations later, without introducing backwards incompatibility.

    As an example, my web framework supports ORM with declaratively defined field filters. You get to declare how to filter the input and output column and it just does it for you (for example automatically converting the native language date() instance to a dateTime string for the database, and back).

    The initial implementation was naive, slow, it looped through all data fields looking if their definition has a filter and applying it.

    I didn't have the time for better, but I knew how to fix it later from that very moment, without changing the public API's even a tiny bit.

    In a later project, I had to process more data in the business logic layer, so filters showed their ugly side. Few preprocessing steps and special case branching later, they were flying, and producing the same results in an order of magnitude less time.

  • sol (unregistered)

    I wasn't going to go there, but it called a database for a reason... the only job a man can get where he starts at the top is digging a hole... a never ending hole... better re-enforce the sides they are collapsing again...

    CAPTCHA: muhahahaha <-- mikey likes it

    really though. First come the plan and requirment defs. then comes the database basic design then run the code generator then optomize indexes... but jebus can we a least make a number a number oO

  • diaphanein (unregistered)

    Not wanting to fall victim to premature optimization is a cowards way of explaining bad code.

    Doing things right (or at least not aggregiously wrong) is not premature optimization. As someone stated above, using correct data types is not an optimization. Using VARCHAR(100) for everything is a sure sign of rectal-cranial inversion.

    I do have one question, though: By chance, would the architect of the system be a perl developer?

  • Asd (unregistered)

    As we saw above, the real WTF = not using Oracle. Hooray for Oracle and its horrible UIs and byzantine configuration!

  • Troy Mclure (unregistered) in reply to ammoQ
    ammoQ:
    George Jansen:
    Well, shucks, folks, the cure is simple. Install Oracle EE, and then you can use function-based indexes

    CREATE INDEX thetab$thecol on thetab(to_date(thecol, 'YYYY-MM-DD'));

    Slow under insert, expensive, baroque--an excellent match for the environment, don't you think?

    This should also solve the wasted-space problem - Oracle handles varchar2 fields more space-efficient.

    Except for the fact that its a cardinal sin to store a date in anything but a date field. Why use a varchar2 when you can use the internal date format and to_char it on the way out the box?

  • (cs) in reply to BiggBru
    BiggBru:
    newt0311:
    Since when did correct data typing in the production database become optimizations???

    This is just like building a car with square wheels, then calling the switch to circular wheels an optimization...

    I like the idea of having a database with nothing but varchar(100) values though. Very enterprisey.

    Particularly if every value is wrapped in XML. That would be Web 2.0, eh?

  • (cs) in reply to diaphanein
    diaphanein:
    Not wanting to fall victim to premature optimization is a cowards way of explaining bad code.

    Doing things right (or at least not aggregiously wrong) is not premature optimization. As someone stated above, using correct data types is not an optimization. Using VARCHAR(100) for everything is a sure sign of rectal-cranial inversion.

    I do have one question, though: By chance, would the architect of the system be a perl developer?

    More like a Pearl Diver!

  • (cs)

    Hey, at least they weren't using CHAR(100), which is what a former co-worker seemed to favor. Even for some ambiguous "flag" field which only used the values 0 or 1.

  • (cs) in reply to diaphanein
    diaphanein:
    Doing things right (or at least not aggregiously wrong) is not premature optimization. As someone stated above, using correct data types is *not* an optimization. Using VARCHAR(100) for everything is a sure sign of rectal-cranial inversion.

    I do have one question, though: By chance, would the architect of the system be a perl developer?

    More likely a PHP developer. Perl developers at least know the difference between an array and a hash ;-).

  • Kevin Lowe (unregistered)

    In shame, I admit that I once wrote a system like that - every DB column was a VARCHAR. I was 19, working my first internship, had no formal education (I wasn't majoring in development at the time), and was working in ASP where everything was a form field anyway. The guy I worked with was as lost as I was.

    I now write much better code, but I still hang my head at how I started my career. (It's still in production, AFAIK.)

  • Pon (unregistered)

    It's unfortunate when people take that whole "Optimise later" thing too far. What they meant was things like bit hacks and such, not architecture :(

  • (cs) in reply to diaphanein
    diaphanein:
    Not wanting to fall victim to premature optimization is a cowards way of explaining bad code.
    Amen! And the term "Premature Optimization" is most often heard from the ones that are responsible for much of that bad code in the first place.
    diaphanein:
    Doing things right (or at least not egregiously wrong) is not premature optimization.
    Double-Amen! It is my experience that scores of developers these days do not understand the differences between "Works" and "Works well", let alone comprehend the existence of a "right way" to do something.

    I am so glad to hear someone else say it, too...

  • (cs)

    The opposite is people who optimize every character of every line too early and often. I've had people go through and optimize stub functions and code that we weren't even going to use once we got to production. You end up with good results but you kill the development process.

  • (cs)

    How is it possible that companies like this are still on the market? - IT systems doesn't make a difference?

  • (cs) in reply to karnokd
    karnokd:
    How is it possible that companies like this are still on the market? - IT systems doesn't make a difference?

    Because profit does not need excellent software systems if you have people involved in the process that understands it's shortcomings. Granted if you had excellent software you might be more profitable, but most companies see the cost of doing so far to great.

  • Michael (unregistered) in reply to karnokd
    karnokd:
    How is it possible that companies like this are still on the market? - IT systems doesn't make a difference?

    Unless your company sells IT systems, then no, the IT systems don't make a difference. For most companies, IT systems don't generate revenue, they can only eliminate wasted expense. Revenue keeps companies on the market, not efficiency.

  • (cs)

    Sounds like a cousin of ACT! Premium for Web...

    Importing a 10000 record contact list will bring a server with the mentioned specifications to its knees for over half an hour.

    Yep, its written in .NET with SQL Server 2000.

  • (cs) in reply to Troy Mclure
    Troy Mclure:
    Except for the fact that its a cardinal sin to store a date in anything but a date field. Why use a varchar2 when you can use the internal date format and to_char it on the way out the box?
    Well, I can only guess why someone would want to do that. I guess it has something to do with magic. You know, the kind of magic where "99-99-9999" is the date that means "open end", while "00-00-0000" means "open beginning", "55-55-5555" means "yet unknown" etc. Likewise for numeric fields, where magic values are not simply -1 or -98765, but strings like "N/A". Definitely stupid, but that's what it takes to make it to the front page of WorseThanFailure.
  • (cs)

    I think the big misconception is that "don't optimise yet" means "do the first thing that pops into your head that works" rather than "do the clearest (most maintainable) thing that works".

    For example, in-place insertion sort is cleaner than mergesort, so implement that first time 'round. The performance benefit from mergesort may be minimal, even negative, so profile before trying to implement it. And just because you think of bogosort first doesn't mean you should use it.

    (Of course, you should be using a standard library sorting algo rather than any of the above, but I figure this works as an example. Mebbe you're writing for an embedded device or something.

    If you want a more solid example, consider the use of linked lists as the buckets in a hashmap. They're generally fast enough, and any structure with better asymptotic complexity will probably run much slower for small buckets.)

  • Pon (unregistered) in reply to Irrelevant
    Comment held for moderation.
  • wilho (unregistered) in reply to skington

    Isnt PHP's arrays based on binary trees instead of hashes, and so it's not actually right to call them hashes?

  • maht (unregistered) in reply to StressBomb

    It's easier to make a fast car reliable than to make a reliable car fast.

  • AGould (unregistered) in reply to Sir Davey
    Sir Davey:
    Chris new that VARCHAR(100) was here to stay.

    I think this should read

    Chris knew that VARCHAR(100) was here to stay.

    No, he forgot some operators: Chris = new that(VARCHAR(100), "stay")

  • Marcin (unregistered)

    This is so stupid, I'm not even going to dignify it with a comment.

  • sol (unregistered)

    So I have to wonder where crazy things like NEVER USE ODER BY use a web server sort fall in at oO Like for instance I have a screen that display (omfg) rows and columns of data.. and I cache it and instead of round tripping back to the database to filter or sort I use what I have in memory already... backing up the original for filters and of course simply sorting the active set of data for sorts...

    I kid you not people have called me stupid for saying why use ORDER BY or why round trip to the database... why use an application cache instead of a seesion for apllication level settings??? Of course I work in VB now so... hahahahahahaha

    CAPTCHA: muhahaha <- mikey still likes it

  • (cs) in reply to jtwine
    jtwine:
    diaphanein:
    Not wanting to fall victim to premature optimization is a cowards way of explaining bad code.
    Amen! And the term "Premature Optimization" is most often heard from the ones that are responsible for much of that bad code in the first place.
    diaphanein:
    Doing things right (or at least not egregiously wrong) is not premature optimization.
    Double-Amen! It is my experience that scores of developers these days do not understand the differences between "Works" and "Works well", let alone comprehend the existence of a "right way" to do something.

    I am so glad to hear someone else say it, too...

    Guys/Gals -- that's the entire point of this WTF. What you just wrote should (hopefully) be obvious to anyone who is reading this site. that's why we laugh at today's post. Of course it is not really optimization to use correct datatypes. That's why this is bad code and that's why we are laughing at it!

    It still amazes me how many people interpret this web site as "programming challenges" or "code snippets to analyze". It's BAD CODE! ALL OF IT! ALWAYS! That's the ENTIRE purpose of this website. If you read about a "technique" in one of the main posts here that sounds stupid, and feel that perhaps you should point this out to us, then you are NOT getting it!

    If you cannot immediately look at code like this, or read the articles and laugh understanding why and how things were done in a WTF manner, then, honestly, this is NOT the site for you.

  • ErikTheRed (unregistered)

    Hasn't anyone heard of CYA memos? The ones you write where you say things like:

    "Failure to use proper datatypes will severly impact performace."

    And then when the finger pointing gets hot and furious, you kick said e-mail (along with the one from your boss telling you not to do it) up the org chart a few notches. This is how you take your boss's salary and apply it to more important things.

  • sol (unregistered) in reply to Jeff S
    Jeff S:
    jtwine:
    diaphanein:
    Not wanting to fall victim to premature optimization is a cowards way of explaining bad code.
    Amen! And the term "Premature Optimization" is most often heard from the ones that are responsible for much of that bad code in the first place.
    diaphanein:
    Doing things right (or at least not egregiously wrong) is not premature optimization.
    Double-Amen! It is my experience that scores of developers these days do not understand the differences between "Works" and "Works well", let alone comprehend the existence of a "right way" to do something.

    I am so glad to hear someone else say it, too...

    Guys/Gals -- that's the entire point of this WTF. What you just wrote should (hopefully) be obvious to anyone who is reading this site. that's why we laugh at today's post. Of course it is not really optimization to use correct datatypes. That's why this is bad code and that's why we are laughing at it!

    It still amazes me how many people interpret this web site as "programming challenges" or "code snippets to analyze". It's BAD CODE! ALL OF IT! ALWAYS! That's the ENTIRE purpose of this website. If you read about a "technique" in one of the main posts here that sounds stupid, and feel that perhaps you should point this out to us, then you are NOT getting it!

    If you cannot immediately look at code like this, or read the articles and laugh understanding why and how things were done in a WTF manner, then, honestly, this is NOT the site for you.

    I don't know everyhing (neither do you), and sometimes it is a bit hard to spot the WTF. SO imagine if you will that I learn by figuring out WTF the WTF is when I don't know WTF the WTF is right off. WTF learning is the real WTF after all... I mean god forbid I come here to be see if I don't know something instead of nurturing my god complex... those god complex guys make the best WTF's after all...

    WTF do you mean I made A WTF your the WTF for thinking I "god of programming" don't know a WTF when I see a WTF...

  • (cs) in reply to ErikTheRed
    ErikTheRed:
    Hasn't anyone heard of CYA memos? The ones you write where you say things like:

    "Failure to use proper datatypes will severly impact performace."

    And then when the finger pointing gets hot and furious, you kick said e-mail (along with the one from your boss telling you not to do it) up the org chart a few notches. This is how you take your boss's salary and apply it to more important things.

    Our company has a nice method to circumvent this. Step 1: You can not create a local folder in Outlook to save messages to. Step 2: They delete EVERYTHING older than 2 months from all mailboxes.

    So by the time the finger pointing starts you have no copy of the email unless you saved it in a text file, but of course we all know you could have simply forged that and there is no proof left anywhere in the system.

  • (cs) in reply to sol
    sol:
    I don't know everyhing (neither do you), and sometimes it is a bit hard to spot the WTF. SO imagine if you will that I learn by figuring out WTF the WTF is when I don't know WTF the WTF is right off. WTF learning is the real WTF after all... I mean god forbid I come here to be see if I don't know something instead of nurturing my god complex... those god complex guys make the best WTF's after all...

    WTF do you mean I made A WTF your the WTF for thinking I "god of programming" don't know a WTF when I see a WTF...

    I think we reached WTF overload on this one.

  • A Nonny Mouse (unregistered)

    As tech lead at his company, surely Chris should have approved the DB design before it ever made it into development?? He must known the technical level of whoever created the db and wanted to check their stuff before using it? Shirley?

  • ElQuberto (unregistered)

    This does have the added benefit of not having to patch your system for DST changes. I think. We'll see if it works I guess.

  • sol (unregistered) in reply to KattMan
    KattMan:
    sol:
    I don't know everyhing (neither do you), and sometimes it is a bit hard to spot the WTF. SO imagine if you will that I learn by figuring out WTF the WTF is when I don't know WTF the WTF is right off. WTF learning is the real WTF after all... I mean god forbid I come here to be see if I don't know something instead of nurturing my god complex... those god complex guys make the best WTF's after all...

    WTF do you mean I made A WTF your the WTF for thinking I "god of programming" don't know a WTF when I see a WTF...

    I think we reached WTF overload on this one.

    yeah, I am very bored today...

  • Ultimape (unregistered) in reply to KattMan
    KattMan:
    ErikTheRed:
    Hasn't anyone heard of CYA memos? The ones you write where you say things like:

    "Failure to use proper datatypes will severly impact performace."

    And then when the finger pointing gets hot and furious, you kick said e-mail (along with the one from your boss telling you not to do it) up the org chart a few notches. This is how you take your boss's salary and apply it to more important things.

    Our company has a nice method to circumvent this. Step 1: You can not create a local folder in Outlook to save messages to. Step 2: They delete EVERYTHING older than 2 months from all mailboxes.

    So by the time the finger pointing starts you have no copy of the email unless you saved it in a text file, but of course we all know you could have simply forged that and there is no proof left anywhere in the system.

    thats illigal... there are a bunch of accountablity acts designed against this particular "cheat". Its what enron did ;)

  • (cs) in reply to Ultimape
    Ultimape:
    KattMan:
    ErikTheRed:
    Hasn't anyone heard of CYA memos? The ones you write where you say things like:

    "Failure to use proper datatypes will severly impact performace."

    And then when the finger pointing gets hot and furious, you kick said e-mail (along with the one from your boss telling you not to do it) up the org chart a few notches. This is how you take your boss's salary and apply it to more important things.

    Our company has a nice method to circumvent this. Step 1: You can not create a local folder in Outlook to save messages to. Step 2: They delete EVERYTHING older than 2 months from all mailboxes.

    So by the time the finger pointing starts you have no copy of the email unless you saved it in a text file, but of course we all know you could have simply forged that and there is no proof left anywhere in the system.

    thats illigal... there are a bunch of accountablity acts designed against this particular "cheat". Its what enron did ;)

    I know that, but what I don't know is if there are any exceptions to this rule. I haven't found one yet.

  • tc (unregistered) in reply to Asd

    Speaking of byzantine database configurations, has anyone ever worked with DB2 ?

  • Expat (unregistered)

    Another WTF is why nobody mentioned Mr. Michael A. Jackson having an interview with the "Bobs" a la Michael Bolton in "Office Space"

  • diaphanein (unregistered) in reply to KattMan
    KattMan:
    ErikTheRed:
    Hasn't anyone heard of CYA memos? The ones you write where you say things like:

    "Failure to use proper datatypes will severly impact performace."

    And then when the finger pointing gets hot and furious, you kick said e-mail (along with the one from your boss telling you not to do it) up the org chart a few notches. This is how you take your boss's salary and apply it to more important things.

    Our company has a nice method to circumvent this. Step 1: You can not create a local folder in Outlook to save messages to. Step 2: They delete EVERYTHING older than 2 months from all mailboxes.

    So by the time the finger pointing starts you have no copy of the email unless you saved it in a text file, but of course we all know you could have simply forged that and there is no proof left anywhere in the system.

    There's always hardcopy... Just remember to keep that desk draw locked.

  • diaphanein (unregistered) in reply to tc
    tc:
    Speaking of byzantine database configurations, has anyone ever worked with DB2 ?

    Yes. I found it was typically best to avoid using their client tools and stick to doing everything manually via command line processor.

    After figuring that out, I found it to be rather pleasurable, at least until we started playing version pong w/ DB2 Connect fixpacks towards the end of v6's lifetime and v7. (Microsoft: Where would you like to go today? IBM: What feature would you like to have today, and what features are you willing to do without in order to have that one?)

Leave a comment on “We'll Optimize Later”

Log In or post as a guest

Replying to comment #:

« Return to Article