Fix query to get missing foreign key indexes. Thanks to Ronan Dunklau for the patch.