Fix EZP-22913: prevent exponential growth in number of queries when removing image alias attributes