I have a Postgres table
Prices with the columns
Prices get updated regularly and I keep old prices in the table. For a given product, the last price in the table is the current price.
What is the most efficient way to get the last price for a specific product:
product_idand query for the last record
- Add a third column
active(Boolean) to mark the latest price and create a composite index (
- Or something else?