Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

HBASE truncate table question

avatar
Super Collaborator

I am truncating an hbase table but its not emptying it and everytime I truncate it gives me a different count on the table ?

four of the columns on this table have versions =10 set.

I want to empty this table in one command.

hbase(main):001:0>
hbase(main):002:0*
hbase(main):003:0* truncate 'PUR_ACCT_PHX'
Truncating 'PUR_ACCT_PHX' table (it may take a while):
 - Disabling table...
 - Truncating table...
0 row(s) in 9.7210 seconds
hbase(main):004:0> count 'PUR_ACCT_PHX'
Current count: 1000, row: 18220040
1133 row(s) in 0.1700 seconds
=> 1133
hbase(main):005:0> truncate 'PUR_ACCT_PHX'
Truncating 'PUR_ACCT_PHX' table (it may take a while):
 - Disabling table...
 - Truncating table...
0 row(s) in 5.3810 seconds
hbase(main):006:0> count 'PUR_ACCT_PHX'
Current count: 1000, row: 13107118
Current count: 2000, row: 14153506
Current count: 3000, row: 15192260
Current count: 4000, row: 16091274
Current count: 5000, row: 1695352
Current count: 6000, row: 17850480
Current count: 7000, row: 18678016
Current count: 8000, row: 19573032
Current count: 9000, row: 2108730
Current count: 10000, row: 2905364
Current count: 11000, row: 3763048
Current count: 12000, row: 4989356
Current count: 13000, row: 6119274
Current count: 14000, row: 8709736
14447 row(s) in 1.1760 seconds
=> 14447
hbase(main):007:0> truncate 'PUR_ACCT_PHX'
Truncating 'PUR_ACCT_PHX' table (it may take a while):
 - Disabling table...
 - Truncating table...
0 row(s) in 5.3440 seconds
hbase(main):008:0> count 'PUR_ACCT_PHX'
Current count: 1000, row: 1861961
Current count: 2000, row: 80757
2119 row(s) in 0.4240 seconds
=> 2119
hbase(main):009:0>

1 ACCEPTED SOLUTION

avatar
Super Guru

I've never heard of any issue where a truncate does not remove all data from the table (the regions are physically destroyed, so there is no way that the data could persist).

Perhaps you have some process which is writing new data into this table in the background which you forgot about?

View solution in original post

3 REPLIES 3

avatar
Super Collaborator
and this is even more bizzare .. how did the rows increase in the table after truncate command from 1304 to 19962 ?
hbase(main):010:0> count 'PUR_ACCT_PHX'
Current count: 1000, row: 5807472
1304 row(s) in 0.4150 seconds
=> 1304
hbase(main):011:0> truncate 'PUR_ACCT_PHX'
Truncating 'PUR_ACCT_PHX' table (it may take a while):
 - Disabling table...
 - Truncating table...
0 row(s) in 5.5750 seconds
hbase(main):012:0> count 'PUR_ACCT_PHX'
Current count: 1000, row: 12857756
Current count: 2000, row: 13740556
Current count: 3000, row: 14526924
Current count: 4000, row: 15327898
Current count: 5000, row: 16045786
Current count: 6000, row: 16678996
Current count: 7000, row: 17351808
Current count: 8000, row: 17998624
Current count: 9000, row: 18645468
Current count: 10000, row: 19311016
Current count: 11000, row: 19935412
Current count: 12000, row: 20487390
Current count: 13000, row: 214002
Current count: 14000, row: 2799176
Current count: 15000, row: 3449430
Current count: 16000, row: 4322882
Current count: 17000, row: 5288986
Current count: 18000, row: 6087966
Current count: 19000, row: 833559
19962 row(s) in 0.9620 seconds
=> 19962

avatar
Super Guru

I've never heard of any issue where a truncate does not remove all data from the table (the regions are physically destroyed, so there is no way that the data could persist).

Perhaps you have some process which is writing new data into this table in the background which you forgot about?

avatar
Super Collaborator

yes you are right .. I sqoop process was running in background .