@Override
	public String transform(final String input) {
		final List<String> unusedIndices = new ArrayList<String>();

		/*
		 * Process USING INDEX clauses and collect the names of unused indices.
		 */
		final Pattern usingIndexPattern = Pattern.compile("(?is)\\busing\\s+index(" + listUsingIndexPatterns() + ')');
		final Matcher usingIndexMatcher = usingIndexPattern.matcher(input);
		while (usingIndexMatcher.find()) {
			final String indexName = usingIndexMatcher.group(2);
			if (indexName == null) {
				continue;
			}
			final int i = indexName.indexOf('.');
			final String shortIndexName = i == -1 ? indexName : indexName.substring(i + 1);
			unusedIndices.add(shortIndexName);
		}
		final String s = usingIndexMatcher.replaceAll("");

		/*
		 * Process CREATE INDEX statements.
		 */
		final Pattern createIndexPattern = Pattern.compile("(?is)" + CREATE_INDEX_PATTERN + "\\s*(;)");
		final Matcher createIndexMatcher = createIndexPattern.matcher(s);
		if (createIndexMatcher.find()) {
			final StringBuffer builder = new StringBuffer();
			do {
				final String indexName = createIndexMatcher.group(3);
				final int i = indexName.indexOf('.');
				final String shortIndexName = i == -1 ? indexName : indexName.substring(i + 1);
				if (unusedIndices.contains(shortIndexName)) {
					System.out.println("Unused index will be removed: " + shortIndexName);
				}
				/*
				 * If the index is not in the unused list,
				 * then apply the regular filter.
				 *
				 * Otherwise, remove the subsequence.
				 */
				createIndexMatcher.appendReplacement(builder, unusedIndices.contains(shortIndexName) ? "" : "$1$5");
			} while (createIndexMatcher.find());
			createIndexMatcher.appendTail(builder);
			return builder.toString();
		}

		/*
		 * If threre're no CREATE INDEX statements,
		 * just return the original string.
		 */
		return s;
	}