Postgresql – Efficient way to combine SELECT DISTINCT, ORDER BY, and a small LIMIT
My table is: create table transactions transaction_id integer not null, transaction_timestamp integer not null, input_index smallint, output_index smallint not null, from_id integer, to_id integer not null, input_value real, output_value real not null, constraint unique_transactions unique (transaction_id, from_id, to_id) ); with…