Searched and searched. Not sure how to use Explain/Analyze to answer this, without constructing really large test tables and I don't have the means or time to pursue that. Certainly someone can confidently answer this likely simple question for me and save me hours of testing to find out.
I have a table which looks something like this:
id | destination_id | key | value | json_profile_data | deleted_bool | deleted_timestamp
The key and value were the original use of the table, but we recently began storing json arrays instead and now the key/value fields are unused. I want to add 3 new bits of data to this record id. My instinct is to make new columns in each row for the 3 new fields, but my associate wants to use the key/value cols to add the information using the same destination_id.
MY proposal means less rows in the table and looks like this:
id | destination_id | key | value | json_profile_data | claim_code | claim_date | claim_approved_bool | deleted_bool | deleted_timestamp
HIS solution is to add new rows, using the key/value cols to insert the three new bits of info with the same destination_id as their parent row on these new rows.
id | destination_id | null | null | json_profile_data | deleted_bool | deleted_timestamp
id | destination_id | claim_code | value | null | deleted_bool | deleted_timestamp
id | destination_id | claim_date | value | null | deleted_bool | deleted_timestamp
id | destination_id | claim_approved_bool | value | null | deleted_bool | deleted_timestamp
His solution makes 4 rows per destination_id, mine makes 3 new columns on existing row for a given destination_id.
Which is more performant for selects against this table? Or does it matter? I hope I have written this in a way where its clear. Let me know if more elaboration is needed.