prevent invalid SQL query when clearing derelict tags from an unused prefix