![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
This is for a table that holds message board posts. I was planning to set up an `archive` table (identical to the `posts` table), and then set up a cron to automatically copy all rows "WHERE postdate < 20110912235959" (11:59:59pm, 3months ago) to `archive`, then delete those same rows from `posts`. This way, `posts` would stay nice and small. The only problem in doing this is if the user reads a thread that includes posts that are more than 90 days old. These are fairly rare, but do exist. Because of these, I would need to modify my program to recognize when a thread includes those older posts, then make it JOIN appropriately. Before I go through all of that work, I'm curious if there's an easier way to accomplish the same thing (or similar)? I had read up on partitions, and I could write the cron to run every 90 days and just create a partition first, but would MySQL automatically query partitions when they're needed? |
#3
| |||
| |||
|
|
This is for a table that holds message board posts. I was planning to set up an `archive` table (identical to the `posts` table), and then set up a cron to automatically copy all rows "WHERE postdate< 20110912235959" (11:59:59pm, 3months ago) to `archive`, then delete those same rows from `posts`. This way, `posts` would stay nice and small. Why? What is the point? Clearly the size of 'posts' + the size of |
|
The only problem in doing this is if the user reads a thread that includes posts that are more than 90 days old. These are fairly rare, but do exist. Because of these, I would need to modify my program to recognize when a thread includes those older posts, then make it JOIN appropriately. .... and creating a boatload more work for yourself in accessing it. |
|
Before I go through all of that work, I'm curious if there's an easier way to accomplish the same thing (or similar)? I had read up on partitions, and I could write the cron to run every 90 days and just create a partition first, but would MySQL automatically query partitions when they're needed? |
#4
| |||
| |||
|
|
This is for a table that holds message board posts. I was planning to set up an `archive` table (identical to the `posts` table), and then set up a cron to automatically copy all rows "WHERE postdate< 20110912235959" (11:59:59pm, 3months ago) to `archive`, then delete those same rows from `posts`. This way, `posts` would stay nice and small. The only problem in doing this is if the user reads a thread that includes posts that are more than 90 days old. These are fairly rare, but do exist. Because of these, I would need to modify my program to recognize when a thread includes those older posts, then make it JOIN appropriately. Before I go through all of that work, I'm curious if there's an easier way to accomplish the same thing (or similar)? I had read up on partitions, and I could write the cron to run every 90 days and just create a partition first, but would MySQL automatically query partitions when they're needed? |
#5
| |||
| |||
|
|
This is for a table that holds message board posts. I was planning to set up an `archive` table (identical to the `posts` table), and then set up a cron to automatically copy all rows "WHERE postdate < 20110912235959" (11:59:59pm, 3months ago) to `archive`, then delete those same rows from `posts`. This way, `posts` would stay nice and small. The only problem in doing this is if the user reads a thread that includes posts that are more than 90 days old. These are fairly rare, but do exist. Because of these, I would need to modify my program to recognize when a thread includes those older posts, then make it JOIN appropriately. Before I go through all of that work, I'm curious if there's an easier way to accomplish the same thing (or similar)? I had read up on partitions, and I could write the cron to run every 90 days and just create a partition first, but would MySQL automatically query partitions when they're needed? |
#6
| |||
| |||
|
|
Don't bother. Seriously, you're complicating something for no particular benefit, it'll only make things harder to program and harder to find, and even if you're absolutely determined to do a lot of unnecessary work, the right way to handle it is to periodically scan all the message threads, find the ones in posts that have ALL of the messages in them older than three months, and archive the whole thread at once. That way active things, which are what people are likely to read anyway, all stay in your active pool. |
#7
| |||
| |||
|
|
On Tuesday, December 13, 2011 8:22:09 AM UTC-5, Peter H. Coffin wrote: Don't bother. Seriously, you're complicating something for no particular benefit, it'll only make things harder to program and harder to find, and even if you're absolutely determined to do a lot of unnecessary work, the right way to handle it is to periodically scan all the message threads, find the ones in posts that have ALL of the messages in them older than three months, and archive the whole thread at once. That way active things, which are what people are likely to read anyway, all stay in your active pool. That's not a bad plan, and doable. I'm really not trying to solve a problem, just trying to do some "premature optimization", as Jerry likes to say :-) |
|
I currently have 38 `posts` tables, for 38 separate forums. I'm planning to merge these in to one table for the sake of making moderating easier, with an added column to designate to which forum the post belongs. So, where my largest `posts` table currently has 1.4 million rows, this will increase it to around 10 million, with a potential growth of several million a year. I figured that reducing the table from 10 million rows to closer to 750,000 would help speed things up a little, and help prevent future slow queries when it becomes 15, 20, or 30 million rows. Currently, in the table with 1.4 million rows, a normal query only takes 0.0005 seconds, so this is probably moot, anyway. I mean, it could be 1,000 times slower, and still not be noticeable to the regular user. But, this is my typical slow season, so I just figured that it's a good time to mess around. With that in mind, do you still think that minimizing the table size is pointless? |
![]() |
| Thread Tools | |
| Display Modes | |
| |