I have this long winded query
select i.id,i.name, i.item_type_id, (select it.name from items it, relations rel, relation_types relType where it.id=rel.to_id and rel.from_id=i.id and rel.relation_type_id=relType.id and relType.name='CityCtountry') as cityCountry from items i where i.item_type_id=2;
Cut the long story short, we inherited database from customer that hasn't been happy with other company, but so far they refuse to let as redesign it so we have to deal with what we have.
At the moment there is some 8k entries and about half of them are cities that I need to get from DB including a name of country they belong to. Above query takes some 22sec to accomplish this.
Anyone up to challenge of making it more efficient? (DB redesign is out of question as customer refused :'( )