I have a database of automobile classified listings.
After 90 days, the classified listing is no longer valid to be displayed (the listing expires); however, I want to retain the listing for archive purposes.
Question: From a database design best practice perspective as well as query performance, is it better to keep the old listing A) in the same table as the current listing or B), move the expired listing over to an expired table and delete that listing from the current listing table?
In other words,
Option A):
table_classified_listing:
car_id
expired = true | false
...
Option B):
// only current listing in this table (expired = false)
table_classified_listing:
car_id
...
// only expired listing in this table (expired = true)
expired_table_classified_listing:
car_id
...
UPDATE:
My concern with Option A, is that in my MySQL database - when I run EXPLAIN, it say that it's using the expired as the primary key to index on. However, what's more important to my query search performance is for it to use the price field since I'm doing a search based on the price > X. Hence why I'm considering to chose option B.
Option A) that way you have all your data in one place and can more easily create queries for reporting, listing a users historical entries etc. Any speed issues should be mitigated by the database's index on that column. Option B) is premature optimisation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With