Efficiently get the last record
Where appropriate, the database engine can do a backwards scan, ie go straight to the end of the index and work backwards so it's nice and efficient.  You can see this on your query execution plans under the 'Scan Direction' attribute of scan operators.  For your example, with your composite primary key on WarehouseId,OrderId then this will work:



As you are doing select * the clustered index already covers the whole query so no additional bookmark lookups are required.