Reputation: 945
I want to update partitions using below code.
msck repair table_name
(I can't use the other options such as refresh statement like that)
But I don't know the best way to update partitions.
1) I run that code every minutes.
2) I select the partitions using show command then if partitions doesn't exists then run that code.
show partitions table_name
Which is the best way to update partition (the other option is okay), so there is no limitation to search data ?
Would you give me an advice?
Upvotes: 1
Views: 4299
Reputation: 778
another option would also be
ALTER TABLE tblName UPDATE PARTITIONS;
Upvotes: 0
Reputation: 1058
Command msck repair table_name
is expensive one. You can use command ADD PARTITION
.
E.g.
ALTER TABLE tblName ADD PARTITION (dt='2008-08-08', country='us') location '/path/to/us/part080808'
If you don't want to check if partitions exists or not, simply use IF NOT EXISTS
. It will create partition if not exists.
ALTER TABLE tblName ADD IF NOT EXISTS PARTITION (dt='2008-08-08', country='us') location '/path/to/us/part080808'
Upvotes: 4