what is the best way to get distinct records from the table containing 500 mln records? table structure is id1, id2, id3, upload_date. sample data
id1 id2 id3 upload_date
1 ab cd 20240525,
2 null gh 20240331,
2 null gh 20240228
needed result
id1 id2 id3 upload_date
1 ab cd 20240525,
2 null gh 20240331
there can be null in all columns except id1 that is the key and upload_date. if i use groupping by max(upload_date) because of NULLs i get duplications. if i use nvl for null columns, than as a result i miss nulls, when i use select distinct id1, id2, id3, i don’t get max(upload_date) that is required. maybe row_numner(over partition by id1 order by upload_date desc) as row_id and get from there everything with row_id = 1? but will it wotk fine for 500 mln records?