The company I work for has many hospitals as client, and most of them use the same set of applications. One of those applications (which will be kept unnamed) is always giving us performance problems. Through time we discovered many design problems in its database structure, such as not using primary keys or foreign keys, storing dates in separate year, month, day fields,….
Also the developers seemed to be very into using cryptic names for the table and field names (all table names are like on150, on010, pt010, on070, zv054, … with field names as tgcde, innr1, crcmg, …), which is really handy when you have to tune a query. Another nice design decision they made was to include a column in each table storing the table name, and then include this column as leading column in almost every single indexes (including in the unique indexes).
A couple of days ago we were asked again to tune 3 custom queries, which started to take hours (days) to run after the application had been upgraded. Unlike other occasions, this time we did manage to receive a part of the db layout from the application vendor, including short descriptions for the tables and columns.
From the moment I looked at the documenation, things fell into place.
You see, I’m old enough to still had a cobol course at college, and the documentation layout remembered me very much to cobol key-sequenced files.
Apparently, when they switched to using oracle they just took the files and recreated them as tables. Without making any further change in the db design. Neither did their developers made the mentally switch towards “set oriented” programming (read: sql) to retreive data, but instead continued to “read” from the tables as they were still using files (In the email conversation I had with their customer support, they where actually still speaking of files instead of tables). Even the mystery of the column storing the table name was explained, as each “file” layout in the documentation had the sentence: “number of record formats in this file” next to it… .
Of course, knowing why the application has such a dreadful design does not help me much to rewrite the sql statements. But at least it stopped me from willing to kill the developers, as I now know that they just don’t realize that they are no longer working with key-sequenced files, but with a relational database instead.
Ok, I admit… I still want to torture them. But just a little bit