Index the categories and add some query functions.