Re: I could not agree more
I spent a whole afternoon going through vendor's code to work out why a weekly invoice run had interrupted my pub lunch two Fridays running. It was causing the database engine to use more & more memory until it ran out of its allocation. I eventually drilled down to repeated statements that asked the engine to allocate memory without freeing it, buried in deeply nested loops. I showed them how to allocate it once and then reuse it.
A while later I had a gig with that vendor to do the on-site install of a part-custom set-up for a big customer. When we got round to testing I found it was going to take over 24 hours to load each day's data. It looked very odd, a single database engine thread seemed to be doing all the work. It transpired that this was even worse than the previous. They were just running in-line SQL statements to load each line of data rather than a PREPAREd statement or anything more sophisticated. All the SQL parsing was done by the thread handling the connection to the application. Once parsed the job was distributed over multiple threads as expected but the load on each of these was negligible compared to the thread needlessly parsing the same SQL.