An LSI uses the same partition key as the base table but allows a different sort key. A GSI can have a different partition key and sort key from the base table.
Queries on an LSI require the partition key because it shares the partition key with the base table. GSI queries require the partition key of the GSI, which can be different.
LSI requires the partition key (HASH) to be the same as the base table's partition key. The sort key (RANGE) can be different. Option A correctly sets UserId as HASH and Timestamp as RANGE.
GSI allows a different partition key and sort key from the base table, enabling queries on multiple key combinations. LSI shares the partition key with the base table, limiting flexibility.
LSI requires the partition key to be the same as the base table's partition key. If different, DynamoDB throws a ValidationException indicating this mismatch.