In this article I will discus about something i have initiated in Vertica Storage Concepts. This Is something that DW admin that migrate from SQL Server platform or Oracle must understand when working with Vertica database as their DW database engine. So we all now by now that Vertica is storing it's data in WOS or ROS containers(I went and explained this concepts in previous articles). ROS container are write-once and again I will say write-once, what write-once really means ? Well if you have 1 or many rows of data stored in one ROS container and you decide you want to remove or update one of them the ENTIRE ROS CONTAINER MUST BE RE-CREATED. So after we decide to update an existing data this are the steps that Vertica will need to follow the steps bellow:
CREATE TABLE TEST(NAME VARCHAR(10));
(dbadmin@:5433) [dbadmin] * INSERT INTO TEST VALUES('ADRIAN');
-[ RECORD 1 ]
OUTPUT | 1
(dbadmin@:5433) [dbadmin] select * from storage_containers where projection_name='TEST_super';
-[ RECORD 1 ]-------+------------------
node_name | v_d_node0001
schema_name | public
projection_id | 45035996273721452
projection_name | TEST_super
storage_type | WOS
storage_oid | 45035996273721463
total_row_count | 1
deleted_row_count | 0
used_bytes | 16384
start_epoch | 1
end_epoch | 1
grouping | ALL
segment_lower_bound | 0
segment_upper_bound | 4294967295
is_sorted | f
location_label |
delete_vector_count | 0
Move your data from WOS to ROS by using the DO_tm_task('MOVEOUT') operation.
(dbadmin@:5433) [dbadmin] * SELECT DO_tm_task('MOVEOUT');
-[ RECORD 1 ]-------------------------------------------------------------------
DO_tm_task | Task: moveout
(Table: public.TEST) (Projection: public.TEST_super)
(dbadmin@:5433) [dbadmin] select * from storage_containers where projection_name='TEST_super';
-[ RECORD 1 ]-------+------------------
node_name | v_d_node0001
schema_name | public
projection_id | 45035996273721452
projection_name | TEST_super
storage_type | ROS
storage_oid | 45035996273721571
total_row_count | 1
deleted_row_count | 0
used_bytes | 79
start_epoch | 1
end_epoch | 1
grouping | PROJECTION
segment_lower_bound | 0
segment_upper_bound | 4294967295
is_sorted | t
location_label |
delete_vector_count | 0
(dbadmin@:5433) [dbadmin] * select storage_path from disk_storage where storage_usage like '%DATA%';
storage_path
-----------------------------------
/home/dbadmin/d/v_d_node0001_data
(dbadmin@:5433) [dbadmin] * ! find /home/dbadmin/ -iname 45035996273721571
/home/dbadmin/d/v_d_node0001_data/571/45035996273721571
(dbadmin@:5433) [dbadmin] * ! tree /home/dbadmin/d/v_d_node0001_data/571
/home/dbadmin/d/v_d_node0001_data/571
-- 45035996273721571
|-- 45035996273721571_0.fdb
-- 45035996273721571_0.pidx
(dbadmin@:5433) [dbadmin] * select ps.projection_name, ps.row_count, ps.ros_count,sc.storage_oid from v_monitor.projection_storage ps
join v_monitor.storage_containers sc on ps.projection_id=sc.projection_id
where anchor_table_name = 'TEST';
-[ RECORD 1 ]---+------------------
projection_name | TEST_super
row_count | 1
ros_count | 1
storage_oid | 45035996273721571
(dbadmin@:5433) [dbadmin] * UPDATE TEST SET NAME='DBA' WHERE NAME='ADRIAN';
-[ RECORD 1 ]
OUTPUT | 1
(dbadmin@:5433) [dbadmin] select ps.projection_name, ps.row_count, ps.ros_count,sc.storage_oid from v_monitor.projection_storage ps
dbadmin- join v_monitor.storage_containers sc on ps.projection_id=sc.projection_id
dbadmin- where anchor_table_name = 'TEST';
-[ RECORD 1 ]---+------------------
projection_name | TEST_super
row_count | 2
ros_count | 2
storage_oid | 45035996273721571
-[ RECORD 2 ]---+------------------
projection_name | TEST_super
row_count | 2
ros_count | 2
storage_oid | 45035996273722143
(dbadmin@:5433) [dbadmin] select do_tm_task('mergeout');
-[ RECORD 1 ]--------------------------------------------------------------------
do_tm_task | Task: mergeout
(Table: public.TEST) (Projection: public.TEST_super)
(dbadmin@:5433) [dbadmin] select ps.projection_name, ps.row_count, ps.ros_count,sc.storage_oid from v_monitor.projection_storage ps
dbadmin- join v_monitor.storage_containers sc on ps.projection_id=sc.projection_id
dbadmin- where anchor_table_name = 'TEST';
-[ RECORD 1 ]---+------------------
projection_name | TEST_super
row_count | 2
ros_count | 1
storage_oid | 45035996273722437
(dbadmin@:5433) [dbadmin] * select purge_table('test');
-[ RECORD 1 ]----------------------------------------------------------------------------
purge_table | Task: purge operation
(Table: public.TEST) (Projection: public.TEST_super)
Count again the number of containers that are present for our TEST table after the purge statement.
See we have a new container present.
(dbadmin@:5433) [dbadmin] select ps.projection_name, ps.row_count, ps.ros_count,sc.storage_oid from v_monitor.projection_storage ps
dbadmin- join v_monitor.storage_containers sc on ps.projection_id=sc.projection_id
dbadmin- where anchor_table_name = 'TEST';
-[ RECORD 1 ]---+------------------
projection_name | TEST_super
row_count | 1
ros_count | 1
storage_oid | 45035996273722797
(dbadmin@:5433) [dbadmin] ! tree /home/dbadmin/d/v_d_node0001_data
/home/dbadmin/d/v_d_node0001_data
|-- 143
|-- 147
|-- 151
|-- 153
|-- 437
|-- 441
|-- 445
|-- 447
|-- 571
|-- 575
|-- 797
| -- 45035996273722797
| |-- 45035996273722797_0.fdb
| -- 45035996273722797_0.pidx
-- 801
-- 45035996273722801
|-- 45035996273722801_0.fdb
-- 45035996273722801_0.pidx
(dbadmin@:5433) [dbadmin] * ! find /home/dbadmin/ -iname 45035996273721571