Click here to Skip to main content
15,885,757 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: Worst practise - asking a question without searching... Pin
Ravi Sant2-Mar-11 5:14
Ravi Sant2-Mar-11 5:14 
GeneralRe: Worst practise - asking a question without searching... Pin
fjdiewornncalwe3-Mar-11 8:58
professionalfjdiewornncalwe3-Mar-11 8:58 
GeneralRe: Worst practise - asking a question without searching... Pin
Ed Nutting3-Mar-11 9:06
Ed Nutting3-Mar-11 9:06 
GeneralRe: Worst practise - asking a question without searching... Pin
BillW3314-Mar-11 6:55
professionalBillW3314-Mar-11 6:55 
GeneralRe: Worst practise - asking a question without searching... Pin
Ed Nutting14-Mar-11 7:24
Ed Nutting14-Mar-11 7:24 
GeneralRe: Worst practise - asking a question without searching... Pin
drummerboy051125-Mar-11 12:31
professionaldrummerboy051125-Mar-11 12:31 
GeneralRe: Worst practise - asking a question without searching... Pin
Lutosław27-Mar-11 11:27
Lutosław27-Mar-11 11:27 
GeneralUltimate Database Fail [updated] Pin
wizardzz1-Mar-11 5:05
wizardzz1-Mar-11 5:05 
So, I recently changed jobs (4 months ago) and have found some humorous legacy code in the past. But nothing, nothing comes close to the database horror I found. For several days, the senior architect and my manager have been trying to figure out why our nightly and weekly stored procedures were taking so long as to time out. As it turns out, neither have and dba experience.

Well today the discussion turned to hiring an outsider to audit the tables, index, stored procedures, etc. I kindly volunteered to have a look myself, kindly pointing out my database experience. After 15 minutes I found the problem.

There is a table called trades, it has ~23,000,000 rows, and is almost always queried by tradeid and date columns. Not surprisingly the primary key consists of tradeid and date. I looked at the indexes and was shocked to see that there was a clustered index made up of open_quantity and order_type; values of which are almost always 0 and 0 or 1 respectively and almost never search criteria. I looked back at the primary key, and it was set to non-clustered.

This table has existed as such for years- recording and reporting positions and trends on a public facing website the entire time.

I was told I earned my pay for the week, but I'm not allowed to just go home Confused | :confused:

Update:
We created a clustered index on the id and time column and kept the original clustered index as a non-clustered index. It did solve the problems we were having, primarily when inserts were extremely fast, select queries would become impossibly slow.
"Life should not be a journey to the grave with the intention of arriving safely in a pretty and well preserved body, but rather to skid in broadside in a cloud of smoke, thoroughly used up, totally worn out, and loudly proclaiming "Wow! What a Ride!"
— Hunter S. Thompson
modified on Tuesday, March 22, 2011 10:30 AM

GeneralRe: Ultimate Database Fail Pin
musefan1-Mar-11 6:22
musefan1-Mar-11 6:22 
GeneralRe: Ultimate Database Fail Pin
wizardzz1-Mar-11 6:25
wizardzz1-Mar-11 6:25 
GeneralRe: Ultimate Database Fail Pin
musefan1-Mar-11 6:36
musefan1-Mar-11 6:36 
GeneralRe: Ultimate Database Fail Pin
AspDotNetDev1-Mar-11 7:26
protectorAspDotNetDev1-Mar-11 7:26 
GeneralRe: Ultimate Database Fail Pin
AspDotNetDev1-Mar-11 7:38
protectorAspDotNetDev1-Mar-11 7:38 
GeneralRe: Ultimate Database Fail Pin
wizardzz1-Mar-11 7:59
wizardzz1-Mar-11 7:59 
GeneralRe: Ultimate Database Fail Pin
AspDotNetDev1-Mar-11 8:35
protectorAspDotNetDev1-Mar-11 8:35 
GeneralRe: Ultimate Database Fail Pin
wizardzz1-Mar-11 8:37
wizardzz1-Mar-11 8:37 
GeneralRe: Ultimate Database Fail Pin
AspDotNetDev3-Mar-11 11:23
protectorAspDotNetDev3-Mar-11 11:23 
GeneralRe: Ultimate Database Fail Pin
Andy Brummer3-Mar-11 10:37
sitebuilderAndy Brummer3-Mar-11 10:37 
GeneralRe: Ultimate Database Fail Pin
AspDotNetDev3-Mar-11 11:22
protectorAspDotNetDev3-Mar-11 11:22 
GeneralRe: Ultimate Database Fail Pin
Andy Brummer3-Mar-11 11:40
sitebuilderAndy Brummer3-Mar-11 11:40 
GeneralRe: Ultimate Database Fail Pin
AspDotNetDev3-Mar-11 12:02
protectorAspDotNetDev3-Mar-11 12:02 
GeneralRe: Ultimate Database Fail Pin
Andy Brummer3-Mar-11 12:22
sitebuilderAndy Brummer3-Mar-11 12:22 
GeneralRe: Ultimate Database Fail Pin
AspDotNetDev3-Mar-11 12:51
protectorAspDotNetDev3-Mar-11 12:51 
GeneralRe: Ultimate Database Fail Pin
wizardzz3-Mar-11 11:55
wizardzz3-Mar-11 11:55 
GeneralRe: Ultimate Database Fail Pin
AspDotNetDev3-Mar-11 12:09
protectorAspDotNetDev3-Mar-11 12:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.