Query based table optimization.