I installed the dev module to take a look at the performance of a module I'm working on, and I noticed 72 instances of "SELECT * FROM url_alias"... which I found a bit odd (since I don't have the path module active).

I traced it to the drupal_get_path_alias() function being called in url()... every time you call l() you're generating a query regardless of wether you have the path module active.

I wrote a one line patch that just adds a module_exist("path") in there before calling drupal_get_path_alias()... no more unnecessary queries.

Comments

matt westgate’s picture

StatusFileSize
new573 bytes

Some modules such as project rely on url aliasing whether or not the path module is enabled. In otherwards the path module can be used internally even if it isn't enabled. So a cleaner patch would be to check if any alias entries exist in the database instead.

Thanks for pointing this out.

dries’s picture

StatusFileSize
new280 bytes

I don't see how the suggested approach is any better. A better approach is to set $map to be non-null. See my attached patch, which I just committed to HEAD and backported to the DRUPAL-4-3 branch.

gábor hojtsy’s picture

Dries, you patch does not seem to solve anything to me... You have added a $map variable to a function, where no $map variable was used... That does not seem to change the behaviour of anything...

dries’s picture

You're right. I reverted the patch in the DRUPAL-4-3 branch.

gábor hojtsy’s picture

Not fixed.

dries’s picture

Can you be more specific? I fixed the issue in HEAD, and it does not appear to be a bug in DRUPAL-4-3.

Anonymous’s picture