Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Phyron's avatar

Tables with more than 5M rows

I have a question about how to better manage a calendar table.

The table has a date field and other informative fields, price, rate id, property id, opened, etc...

The date field is a range according to the id rate, for example, if X rate, has a date of the day 2022-10-10, and the date after 2022-10-20, the price of the first date , would cover from the 10th to the 19th. The doubt I have is that when updating the rows, I must do several calculations, for example if with the previous example I update the price from day 12 to 22, I have to make almost 3 queries. And this can be compounded. Do you think it would be better, than for each rate id, to create a line for each "editable" day (it can be edited from one year before to two years later, and the days prior to a year, would be eliminated to clean the table). In this case, you would only have to update the affectyed rows by days , without having to modify ranges. But I don't know if it would then work slower when reading/writing. There may be +4000 rates or more. And for each, 4 years: 356days4years4000rates -> more than 5M rows

0 likes
2 replies
lbecket's avatar

This explanation is really hard to follow. Can you provide your schema and a more specific example of the desired changes to the data? It shouldn't take you three queries to update dates, but I can't suggest an alternative without first being able to comprehend what you're doing now and why it is as complex as you indicate.

Please or to participate in this conversation.