DB_Admin != ‘efficient’

From the Daily WTF:

After weeks, months, or even years of setting up and preparing to sell, it’s always exciting to get those few customers. Depending on the venture, it may not be worth popping open a bottle of Champagne, but no matter how small the sale, one can’t help but take a few moments to pause and smile before struggling to get that next batch of sales.

By the time the 13,853rd customer rolls around, no one blinks an eye. It’s just business as usual. That is, unless you work at Ruben’s company. When a new customer record is created, their server not only takes a moment to celebrate, but it nearly brings down the entire server with this unique way of finding the next available customer number:

SELECT * FROM customer
WHERE id_customer  != '4' AND id_customer !='10' AND id_customer !='11'
  AND id_customer !='13' AND id_customer !='14' AND id_customer !='15'
  AND id_customer !='16' AND id_customer !='17' AND id_customer !='18'
  AND id_customer !='19' AND id_customer !='20' AND id_customer !='21'
  AND id_customer !='22' AND id_customer !='23' AND id_customer !='24'
  AND id_customer !='25' AND id_customer !='26' AND id_customer !='27'
  AND id_customer !='28' AND id_customer !='29' AND id_customer !='30'
  AND id_customer !='31' AND id_customer !='32' AND id_customer !='33'
  AND id_customer !='34' AND id_customer !='35' AND id_customer !='36'
  AND id_customer !='37' AND id_customer !='38' AND id_customer !='39'
  AND id_customer !='40' AND id_customer !='41' AND id_customer !='42'
  AND id_customer !='43' AND id_customer !='44' AND id_customer !='45'
  AND id_customer !='46' AND id_customer !='47' AND id_customer !='48'
  AND id_customer !='49' AND id_customer !='50' AND id_customer !='51'
  AND id_customer !='52' AND id_customer !='53' AND id_customer !='54'
  AND id_customer !='55' AND id_customer !='56' AND id_customer !='57'
  AND id_customer !='58' AND id_customer !='59' AND id_customer !='60'
  AND id_customer !='61' AND id_customer !='62' AND id_customer !='63' 

  ... snip several thousand lines ...

  AND id_customer !='13789' AND id_customer !='13790' AND id_customer !='13792'
  AND id_customer !='13793' AND id_customer !='13794' AND id_customer !='13795'
  AND id_customer !='13796' AND id_customer !='13797' AND id_customer !='13798'
  AND id_customer !='13799' AND id_customer !='13800' AND id_customer !='13801'
  AND id_customer !='13802' AND id_customer !='13803' AND id_customer !='13804'
  AND id_customer !='13805' AND id_customer !='13806' AND id_customer !='13807'
  AND id_customer !='13808' AND id_customer !='13809' AND id_customer !='13810'
  AND id_customer !='13811' AND id_customer !='13812' AND id_customer !='13813'
  AND id_customer !='13814' AND id_customer !='13815' AND id_customer !='13816'
  AND id_customer !='13817' AND id_customer !='13818' AND id_customer !='13819'
  AND id_customer !='13820' AND id_customer !='13821' AND id_customer !='13822'
  AND id_customer !='13823' AND id_customer !='13824' AND id_customer !='13825'
  AND id_customer !='13826' AND id_customer !='13827' AND id_customer !='13828'
  AND id_customer !='13829' AND id_customer !='13830' AND id_customer !='13831'
  AND id_customer !='13832' AND id_customer !='13833' AND id_customer !='13834'
  AND id_customer !='13835' AND id_customer !='13836' AND id_customer !='13837'
  AND id_customer !='13838' AND id_customer !='13839' AND id_customer !='13840'
  AND id_customer !='13841' AND id_customer !='13842' AND id_customer !='13843'
  AND id_customer !='13844' AND id_customer !='13845' AND id_customer !='13846'
  AND id_customer !='13847' AND id_customer !='13848' AND id_customer !='13849'
  AND id_customer !='13850' AND id_customer !='13851' AND id_customer !='13852'
;
  • Fefy

    This is a crazy but beautiful sql query :D

  • Fred

    select * from DB_ADMIN where SKILLSET is Null :)

  • http://xandria.ca/ Xandria

    o.0

  • Cyan

    And this will be used from now on as a “how to not make queries 101″

  • http://www.facebook.com/profile.php?id=100000222812806 Alexander William Evans

    I’m willing to believe he did it like this intentionally to waste as much company time as he could muster.