Re: Difference between drop and truncate

2017-12-20 Thread zuochangan
Detailed explanation, thanks 

> 在 2017年12月21日,上午11:49,Jeff Jirsa  写道:
> 
> Assume you’re running 3.0 or 3.x - there’s a patch that’ll be in the next 
> releases that speed up truncate significantly - there’s some slowish code in 
> adding the sstables to the transaction log before deleting them, but it’ll be 
> much faster. 
> 
> Truncate marks all the data as removed, and then removes it. It requires all 
> hosts be online. It removes the risk of conflicting CFIDs. It reduces races.
> 
> Dropping the table isn’t guaranteed to hit all hosts at the same time, and 
> recreating it won’t either. It’s far more likely you could have data lost if 
> you’re writing as you drop and recreate vs using truncate. 
> 
> 
> 
> -- 
> Jeff Jirsa
> 
> 
> On Dec 20, 2017, at 7:41 PM, changan zuo  > wrote:
> 
>> Hi,guys
>>We have a very big table. when I excute "truncate table" it takes such a 
>> long time at last show "request timeout ". 
>>well, if I execute drop table which complete very quickly.
>>I cannot see the big difference since they both delete the data.
>>
>>Anyone can explain it to me ? thanks a lot
>> 
>> 
>> 
>>  



Re: Difference between drop and truncate

2017-12-20 Thread Jeff Jirsa
Assume you’re running 3.0 or 3.x - there’s a patch that’ll be in the next 
releases that speed up truncate significantly - there’s some slowish code in 
adding the sstables to the transaction log before deleting them, but it’ll be 
much faster. 

Truncate marks all the data as removed, and then removes it. It requires all 
hosts be online. It removes the risk of conflicting CFIDs. It reduces races.

Dropping the table isn’t guaranteed to hit all hosts at the same time, and 
recreating it won’t either. It’s far more likely you could have data lost if 
you’re writing as you drop and recreate vs using truncate. 



-- 
Jeff Jirsa


> On Dec 20, 2017, at 7:41 PM, changan zuo  wrote:
> 
> Hi,guys
>We have a very big table. when I excute "truncate table" it takes such a 
> long time at last show "request timeout ". 
>well, if I execute drop table which complete very quickly.
>I cannot see the big difference since they both delete the data.
>
>Anyone can explain it to me ? thanks a lot
> 
> 
> 
>