I have a table with a primary key of 2 values - id and timestamp. The table contains multiple rows for each item_id, and the timestamp is what should make it unique. Can I execute an efficient query considering this setup? I want to find the latest appearance of an item_id. Any ideas?
CREATE TABLE IF NOT EXISTS table (
item_id varchar(30) NOT NULL,
ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
...
PRIMARY KEY (item_id, ts)
);