SQL Join? na I know a better way.....
-
Once had the great pleasure of having to examine our banks End of Day processor. part of the app had the ability to show the account transaction records, which they used to dump transactions to luvly excel spreadsheets for analysis.... the guy who wrote it obviously had never heard of SQL joins though he used a SQL statement along the lines of "Select * from tran" to retrieve all the records, then entered into a mother loop.
for each row in result for each column in the result if the datatype is a int, it must be a foreign key do a whole load of messin to work out the foreign key table so do another sql statement to pull back the foreign key value from another table output the foreign key value else output the value end if next column next row.
worked out that each time a new transaction was entered onto the system this loop would have to do another 60 or so new SQL requests. so instead of one sql query using multiple joins to get foreign key values, this numpty wrote over 60 queries, which fired for each and every row output. and considering this was only a weeee bank, We did only have in the region of 5 million transactions with about another 100,000 or so a month getting added.. and they wondered why it could take ages to display only a few hundred thousand records and output them.......... :mad: