performance - Proper way to create dynamic 1:M SQL table -
Simplified Example: Two tables - People and time goals every time a person walks through the door.
A person could have between 0 and 50 entries in the table repeatedly
What is the most effective and effective way to keep track of these records? Is it
timetable ----------- person_id timestamp
I worry that this table is better than one Million records may be extremely important at the time of inclusion and retrieval rather quickly
Also: Clearly, non-generalized but doing this would be a better idea.
Bar table - ---------- person_id serialized_timestamps_for_the_day Date
For each individual timestamp for individual Need to reach, but only record the query on the date or person's ID.
- Since you need to access individual timestamps 1 ,
serialized_timestamps_for_the_day
can not be considered and will violate 1 NF, due to which A. - On that, you are starting a redundancy:
Date
can be estimated from thecontent of Serialized_timestamps_for_the_day
, and your app code will It will be necessary to make sure that they will never become "Disneynaz", which is weak for bugs. Therefore the first solution, if a modern database on modern hardware can handle just "more than a million records", in this specific case: A composite index on {person_id, timestamp} will allow you to query a person or person by a simple index range scan, which can be very efficient. - If you just need a "date" query, you will need an index on {timestamp}. By searching for a range from 00:00 to 24:00 on the given day, you can easily search for all timestamps within a specific date.
1 Even if you do not query for a personal timestamp, you will see them databases one-by-one I have to write in If you have a serialized field, you first need to read the whole field to add just one value, and then write the whole result in the database, which can be a functionality problem, which is quick And there are other problems, as outlined in the link given above.
2 As a general rule, can be guessed what should not be
< / P>
Comments
Post a Comment