79739002

Date: 2025-08-18 16:21:01
Score: 1.5
Natty:
Report link

The given query selects 10 random rows and then returns the unique_id of the row with the highest price among them. However, using ORDER BY RAND() is very expensive when the table has a large number of rows.

To optimize this, we can:

  1. Pick a random offset within the table.

  2. Retrieve 10 consecutive rows starting from that offset.

Reasons:
  • No code block (0.5):
  • Low reputation (1):
Posted by: Ritesh Sanchala