MySQL + middlegen = Scaling Issue
Flashback to J2EE Dev times: During the development of an internal J2EE framework, I came across a scaling issue when using middlegen to generate my CMP beans when I hit a certain number of tables (60+ or so). From then on it started to become quite painful, as middlegen would appear to hang for minutes while it analysed the table structures. Looking at the mySQL log, it appeared the driver was requesting the create table syntax of every table in my database multiple times.
First I looked into the source of middlegen, to see if it was doing something wacky… It was using the DatabaseMetaData.getImportedKeys() method to determine what foreign keys refer to the table currently getting analysed. This seemed reasonable to me so I decided to look into the mysql driver’s implementation of this function to see what was going on. Turns out, the way the driver figures this out is by getting the create statement of every table in the db, checking to see if it contains a foreign key reference to the table getting tested. Because middlegen was doing this for every table, it would mean that for each table in the db, a “show create table” call was executed for every other table in the db (n * n)…. No wonder this didn’t scale all to well…
To get around this problem I hacked to driver apart to forcibly cache the results from the ‘show create’ statement, so next time DatabaseMetaData.getImportedKeys() was called, it would use locally cached information.. not the most elegant solution but it worked.
Unfortunately I don’t have the code anymore (which I cant believe.. very embarrassing… I believe I always thought I would clean it up before putting it under source control... well it was over a year ago…), but I still have a jar file of the hacked driver which I use when generating the middlegen beans. Needless to say, this is not production quality, hell, for all I know, the a more elegant solution has been rolled into the driver codebase… either way, I thought I would make the jar available here just in case…
Now back to today, quick update on what’s been happening: I’ve worked on buttonator.com for a couple of days adding accounts, and multilingual support (Chinese, Japanese and Arabic for now). Also added the concept of a hotlink template… During this I had to use the caching of ruby: gotta say its pretty darn cool. After coming from cocoon, it’s nice to be able to use something so easy and logical. We should be rolling of v2 beta of buttonator.com sometime this week.
References (12)
-
Response: FollowSurround yourself with only people who are going to lift you higher -
Response: ReadedHe who does not know how to be silent will not know how to speak -
Response: adult dating personal adsAdult Dating Deluxe -
Response: How to Pick Up and Date Women Tips BlogBlog with Approach, Pick Up and Date Women Tips -
Response: car insuranceAs the net continues to add christian online dating services web sites, we'll try to bring them to you. -
Response: pattaya real estate -
Response: auto insurance for young driversCheap auto insurance for teenagers -
Response: adult personalsadult personals -
Response: For More Information Click Herebig dick man, beautiful ebony woman, sexy black man, sexual intercourse, whoring sluts, webcam whores, internet sex, felatio, sexy transexual, lesbian sex, bisexual honey's cum on my face, fecal matter -
Response: christian datingchristian dating -
Response: christian datingchristian dating -
Response: adult datingI have too many favorites. I can? t pick one all time favorite. As a child I kept rechecking out the different colors of fairy books- ? The Red Fairy? book etc. As an adult my favorites are even harder to pick. ? Good Omens? by Neil Gaiman and Terry...

Reader Comments