private void findIndexUsageInVicinity(TablePairActivity tablePair)
			throws Exception {
		for (Query query : queries) {
			List<String> queryRelations = query.getRelations();
			Set<QueryFilter> queryFilters = query.getSelections();

			String tableA = tablePair.getNameOfTableA();
			String tableB = tablePair.getNameOfTableB();

			// For complex queries with more than 2 tables, and where we haven't
			// found index usage
			if (tablePair.isPair() && tablePair.getUsageIndexA() == 0
					&& tablePair.getUsageIndexB() == 0
					&& queryRelations.size() > 2) {
				for (QueryFilter qa : queryFilters) {
					String targetTable = qa.getLeftAttribute().getTableName();

					if (db.areTablesConnectedInOneToMany(tableA, targetTable)) {
						tablePair.addUsageNearIndexA(query.getTimesUsed());
					} else if (db.areTablesConnectedInOneToMany(tableB,
							targetTable)) {
						tablePair.addUsageNearIndexB(query.getTimesUsed());
					}
				}
			}
		}
	}