Archive for December, 2007

Published by Fabian on 25 Dec 2007

Reduce unneeded Propel SQL queries asking for an ID

When reviewing code that soon should go live, always hunting for optimisation options, I discovered that a table was queried but the data was not used. In this example it was the user query, but i could not find any user names or email addresses on the generated page.

When digging into the action code I noticed a line like this:

$id = $blog_entry->getUser()->getId();

The id was then used for some other stuff, where actually the id was the only thing that was required from the user table.

Naively examining the line there is nothing wrong with it, however, if you know how propel does handle this internally there is a lot to improve. So we want to have PK of the user.

But BlogEntry and User are joined on the FK user_id. What propel does internally is that it obtains the FK user_id from the table (which is easy, it is stored in there like any other member) and has a reference to an object called aUser which is null.
When now doing the getUser() it notices that aUser is null, takes the user_id does a query and stores this to aUser, which is returned.

Did you notice something? Yes we only want to have the value that we already have! Luckily there is also an accessor for user_id, as it behaves totally the same as any other member.

$id = $blog_entry->getUserId();

Of course you could argue why we access an “internal” join attribute like that, but on the other hand, hey the PK of User could be treated the same way as internal, couldn’t it? And as I was doing this anyway very late in development cycle it is quite unlikely that this will change. And even if it would, getUserId() would fail very similar to getUser()->getId()

Of course this brings only performance where no other data of user is required.
To find similar issues yourself, just do a fulltext search fo “()->getId()” (assuming that you PKs are also called id)

Published by Fabian on 20 Dec 2007

1st symfony coding sprint

Today was the first official symfony coding sprint. After joining the IRC in the morning, there was a lot of chat, but no real work done up to noon. Perhaps the french start working late? I used the time to explain that I am not Fabien Potencier. Which was actually pretty hard :-)

I spent most of my time in the afternoon to proofread the new 1.1 documentation and putting the findings into a review wiki page.

In the evening I wanted to do some more coding work and finished two patches for my own tickets. After that I continued writing patches for other open issues, but mainly got distracted by chatting with the nice folks in IRC.

A very nice event. I hope that helped symfony towards 1.1. The maintenance release 1.0.10 was done today.
Apart from that trac recorded a record activity. By time of writing there were 135 activities recorded. Yeehaa.

See you on the next symfony-sprint

Published by Fabian on 16 Dec 2007

The Legend of Zelda – Twilight Princess – great game

I forgot one thing to mention which is keeping me busy. Playing Zelda – Twilight Princess on our Wii. It is an awesome game and I am now through with the main story after 46 hours of playtime. No grinding, no repetition, no endless cutscenes. Games that offer about 1 hour playtime per Euro are rare. Its a nice adventure for beginners and pros. Now I will waste more time on it trying to complete all the sidequests (which are slightly more grind mode).

There are many puzzles, jokes and cool things to discover in this great game. Well done Nintendo.

Published by Fabian on 15 Dec 2007

Way too busy

Sorry folks for quite period on my blog.

I have been very busy an finalizing the relaunch of tempus-vivit.net; So its crunchtime. Plan is still until the end of the year to relaunch it completely rewritten in symfony.

Also I still try to finalize my Sun Certified Java Developer, which is in its nasty 80% done state.

Last but not least, I will start a new job somewhen early 2008, there are a lot of reasons for that that I am not allowed to disclose, but also I was looking for a change. I think I have found something good. More details on this when its closed.

Thanks for having me in your reader :)