on 03-06-2014 8:38 AM
Hello, We decided to partition a table by Hash for the key (GUID) and range for the periods – one partition for each month. Now we are thinking how to make the range dynamic. Should we create the ranges for all the year in advance? Do the empty partitions will influence our performance and memory space? Is there any other way to create partitions automatic for each month – we though about creating a special script for this but what will happen if we miss a period? Thanks, Amir
http://help.sap.com/hana/SAP_HANA_Administration_Guide_en.pdf
Take a good read through the above document at page 133, it should help you in your partitioning quest.
Keep in mind - you can always change the partitioning methods on the fly and put the partitions back together into one piece, so you are not setting anything in stone. Of course, this can take some time with large tables, but it's still possible. At current client in a stage in environment, a 1.6b record table was merged and repartitioned in about 10 hours.
Regards,
Justin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Amir,
Regarding your question, you can create the partitions in advance or you can create them later dynamically. It depends on you. If you want to create a partition each month dynamically, you can use the job scheduling to realize this. You can write the logic of creating a new partition in .xsjs and write the job scheduling in a .xsjob file.
In addition, I've made a test for you according to your scenario.
First I created a partitioned table, multi-level, hash-range.
CREATE COLUMN TABLE TEST_PART (
ID INTEGER PRIMARY KEY,
NAME NVARCHAR(100),
_DATE DATE
) PARTITION BY HASH (ID) PARTITIONS 2, RANGE (MONTH(_DATE)) (
PARTITION '2014-06' <= VALUES < '2014-07',
PARTITION '2014-07' <= VALUES < '2014-08',
PARTITION '2014-08' <= VALUES < '2014-09'
);
When you open the definition of the table and switch to the "Runtime Information" tab, you can find the following info.
Then I added a partition dynamically as follows.
ALTER TABLE TEST_PART ADD PARTITION '2014-09' <= VALUES < '2014-10';
You can find the latest info.
In addition, you can also drop the partition if you do not need it anymore.
ALTER TABLE TEST_PART DROP PARTITION '2014-09' <= VALUES < '2014-10';
Best regards,
Wenjun
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Wenjun,
I have used your method for a date partition in SAP HANA, but I ran into a situation where my date column is defined as Nvarchar and I need to partition this my month.
In this case I wanted to do something like below which is not allowing me to create partitions on existing table.
Any help on this is much appreciated.
ALTER TABLE Testschema.Test_Part
PARTITION BY HASH (ID) PARTITIONS 2, RANGE(LEFT(TestString,6))
(
PARTITION Values = '201406',
PARTITION Values = '201407',
PARTITION OTHERS
);
Regards
Devi
Hi Devi,
Yes, it's not allowed. If you have a look at ALTER TABLE - SAP HANA SQL and System Views Reference - SAP Library, the definition of <partition_expression> is as follows.
<partition_expression> ::= <column_name> | YEAR(<column_name>) | MONTH(<column_name>)
So, LEFT(TestString,6) in your case is not allowed. Please consider to add a date column using "GENERATED ALWAYS AS" in your case.
<col_gen_as_expression> ::= GENERATED ALWAYS AS <expression>
Best regards,
Wenjun
Hi Wenjun,
I Tried using Generated Always As and created new column and used it in the
ALTER TABLE Testschema.Test_Part ADD (TEST1 DATE GENERATED ALWAYS AS (TO_DATE(TestString)));
ALTER TABLE Testschema.Test_Part
PARTITION BY HASH (ID) PARTITIONS 2, RANGE(Month(TEST1))
(
PARTITION Values = '201406',
PARTITION Values = '201407',
PARTITION OTHERS
);
SAP DBTech JDBC: [2048]: column store error: fail to alter partition: [2051] partition specification not valid;The attribute TEST1 is not allowed in a partition specification.
Regards
Devi
Hi Wenjun /Fernando,
I have couple of questions with respect to this partition implementation.
Thanks for the help again.
Regards,
Devi
>Is there a way to check if the given range partition exists already for the table? We are planning to schedule a Job that deletes / Adds new partition on monthly basis.
You can use SELECT * FROM SYS.M_CS_PARTITIONS WHERE ...; to check that. For job scheduling, you can have a look at Scheduling XS Jobs - SAP HANA Developer Guide for SAP HANA Studio - SAP Library
Best regards,
Wenjun
You can have a look at ALTER TABLE - SAP HANA SQL and System Views Reference - SAP Library and ALTER TABLE - SAP HANA SQL and System Views Reference - SAP Library. If you want a job scheduling on monthly basis, every time you just need to add one partition and drop one partition...
Best regards,
Wenjun
It depends on your scenario/hardware/software. What I replied was just about the technical stuff and I did not provide any architecture design. By the way, dynamic tiering is introduced in SAP HANA SPS09 which is also a good idea for managing data cost efficiently.
SAP HANA Dynamic Tiering – SAP Help Portal Page
Best regards,
Wenjun
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Confused on your post. Do you mean to say that you have a multi level partition defined on the table with a hash-range option? This would indicate to me that you always intend to use a GUID value when querying the table, otherwise any advantage of the partitioning in the first level is gone.
In general, for range partitioning you need to define the intervals up front. There will always be an OTHER interval that will catch anything that doesn't meet currently existing intervals. So no need to worry that you will "lose" data, it will just fall into an un optimized bucket. However, when you add new range partition intervals, the OTHER bucket will be split apart if you add intervals that now match data present there.
No performance impact if you have empty intervals, and of course no (maybe a tiny bit) memory will be consumed since their empty.
I would make partition analysis a component of some periodic system activities.
Regards,
Justin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Amir ,
SAP hana till now has not provided options for Dynamic Partition for the tables.
So better, you keep the script and scheduled it with the scheduler.
No need to generate in advance. You can schedule it at the start of every month for next month.
I don't think blank partition will bring your performance down.
Regards ,
Pratik Doshi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.