Optimize groupwise maximum query
Assuming relatively few rows in options for many rows in records. Typically, you would have a look-up table options that is referenced from records.option_id, ideally with a foreign key constraint. If you don’t, I suggest to create one to enforce referential integrity: CREATE TABLE options ( option_id int PRIMARY KEY , option text UNIQUE NOT … Read more