Disadvantage: the created_at as one of the primary key must
ALTER TABLE files PARTITION BY RANGE
(UNIX_TIMESTAMP (created_at))
(PARTITION {$pname} VALUES LESS THAN ({$less_than_time}))
I now want to hidden timestamp to do conditions according to the ID of the
I now put part of the timestamp in the ID, such as the ID is 9777215210102229301,
9777215 of them were part of the time, it is 1509777215 truncated the front three, when I put in storage, I hope that in the corresponding partition by joining together the current time, so I try the following:
selct the CONVERT (CONCAT (left (unix_timestamp (now ()), 3), left (' 9777215210102229301 ', 7)), SIGNED)
Found no problem, you can get the correct time stamp, but I replace it into the partition table to build statement is an error in the
Replace the statement
ALTER TABLE files PARTITION BY
RANGE (CONVERT (CONCAT (left (unix_timestamp (now ()), 3), left (id, 7)), SIGNED))
(PARTITION {$pname} VALUES LESS THAN ({$less_than_time}))
Error:
` ` `
ERROR 1064 (42000) : Constant, random or timezone - dependent expressions in (sub)
Partitioning function are not allowed near ')
PARTITION (' 2017 'VALUES LESS THAN (150981119))' at line 1
` ` `
This also not line
ALTER TABLE files PARTITION BY
RANGE (
UNIX_TIMESTAMP (FROM_UNIXTIME (
CONCAT (left (unix_timestamp (now ()), 3), left (' 9777215210102229301 ', 7)))
)
)
PARTITION (' 2017 'VALUES LESS THAN 150981119)
The great god could help solve
CodePudding user response:
CONVERT (CONCAT (left (unix_timestamp (now ()), 3), left (' 9777215210102229301 ', 7)), SIGNED)-- -- -- -- -- - for the partition, the expression is clearly a problem, the current of time is different, the result of calculation is likely to be different, but the result of the partition is obviously requires a certain
Today, otherwise the same ID is calculated in division 1, should calculate in partition 2 tomorrow, do you think about this and mean?
CodePudding user response:
Partition in mysql, can be carried out on the field, but now you use this function, clearly the value of every day is different, also said in the error message, depends on the time when this calculation can't some,CodePudding user response:
I think if I can add a field, put you calculated the value of this new field, and then partitions