I've created a module to generate my own front page by a straight SQL select from several tables - the idea being partly because I wanted a completely different presentation, partly because I want a large number of articles actually visible on the front page, partly to avoid going through calls to hook_nodeapi etc. So far it has worked very well, and has seriously speeded up my front page presentation.
There is only one drawback: as it stands, it doesn't provide the URL alias links, only node links. So I want to modify the SQL to include the url_alias table. Here is the code (the "titles_settings" table belongs to my front-page module by the way):
select t.uid, f.filepath, f.filemime, t.display_name, t.which_column, t.weight, n.nid, n.title, n.created, n.body, n.teaser, n.sticky, u.dst AS path_alias from {titles_settings} t join {node} n on t.uid=n.uid left outer join {files} f on n.nid=f.nid LEFT JOIN {url_alias} u ON CONCAT('node/', n.nid) = u.src where ( n.status=1 and n.moderate=0 and n.promote=1) order by n.sticky desc, t.which_column, t.weight, t.uid, n.created DESC
This executes fine and produces the result I want. Only problem - it seemed to me that it would be better to have an index on url_alias.src in order to optimise the join, so I created one. But looking at the SQL statement with EXPLAIN I can see that the index is not being used.
Can anyone tell me the reason for this, and the reason for not indexing this field in the first place?