database-partitioning

mysql partitioning with unix_timestamp from variable

 ̄綄美尐妖づ 提交于 2019-12-04 08:57:51
Given this : delimiter // create procedure setup() begin declare d datetime; set d = rounddate(now()); create table s_time (req_id int not null, ser_id int not null, hel_id int not null, posted int unsigned not null, completed int unsigned not null default 0 ) partition by range (completed) (partition p0 values less than ( unix_timestamp(d) ), partition p1 values less than ( unix_timestamp(d + interval 1 day) ) ); end// I get : ERROR 1064 (42000) : Constant, random, or timezone-dependent expression in (sub)partitioning function are not allowed Is there any way to get this to work, or do I have

How do I create a partition for every month of the current year

左心房为你撑大大i 提交于 2019-12-04 08:25:56
I want to partition my data by "MONTH" I am trying this, ALTER TABLE t1 PARTITION BY RANGE(TO_DAYS(FROM_UNIXTIME(transaction_date)))( PARTITION JAN VALUES LESS THAN (TO_DAYS('2013-02-01')), PARTITION FEB VALUES LESS THAN (TO_DAYS('2013-03-01')), PARTITION MAR VALUES LESS THAN (TO_DAYS('2013-04-01')), PARTITION APR VALUES LESS THAN (TO_DAYS('2013-05-01')), PARTITION MAY VALUES LESS THAN (TO_DAYS('2013-06-01')), PARTITION JUN VALUES LESS THAN (TO_DAYS('2013-07-01')), PARTITION JUL VALUES LESS THAN (TO_DAYS('2013-08-01')), PARTITION AUG VALUES LESS THAN (TO_DAYS('2013-09-01')), PARTITION SEP

hibernate insert batch with partitioned postgresql

巧了我就是萌 提交于 2019-12-03 16:52:26
问题 is there a solution for batch insert via hibernate in partitioned postgresql table? currently i'm getting an error like this... ERROR org.hibernate.jdbc.AbstractBatcher - Exception executing batch: org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1 at org.hibernate.jdbc.Expectations$BasicExpectation.checkBatched(Expectations.java:61) at org.hibernate.jdbc.Expectations$BasicExpectation.verifyOutcome(Expectations.java

Dynamic table partitioning in Oracle

一笑奈何 提交于 2019-12-03 12:28:49
I'm in the process of building a database storage for my app consisting on a single table with a huge data volume (hundreds of millions of records). I'm planning on having an index on the date field, since I'll be doing a batch recovery of all the records in a given period of time every now and then (for example, retrieving all records for the following day, at midnight). Since the number of records is huge and performance is an important concern in this system, I would like to know if there is a way I can dynamically partition my table so that I can retrieve the records faster, creating and

How does one do a SQL select over multiple partitions?

倾然丶 夕夏残阳落幕 提交于 2019-12-03 12:00:33
Is there a more efficient way than: select * from transactions partition( partition1 ) union all select * from transactions partition( partition2 ) union all select * from transactions partition( partition3 ); It should be exceptionally rare that you use the PARTITION( partitionN ) syntax in a query. You would normally just want to specify values for the partition key and allow Oracle to perform partition elimination. If your table is partitioned daily based on TRANSACTION_DATE, for example SELECT * FROM transactions WHERE transaction_date IN (date '2010-11-22', date '2010-11-23', date '2010

Drop partitions older than 2 months

青春壹個敷衍的年華 提交于 2019-12-03 09:16:25
I have a table with partition based on date field. Now, I have to write a procedure to drop all partitions older than 2 months i.e. test_date is older than 2 months. How do I do it? create table test_table ( test_id number, test_date date, constraint pk_test primary key (test_id) ) partition by range (test_date) ( PARTITION pt01122012 VALUES LESS THAN (TO_DATE('01-DEC- 2012', 'DD-MON-YYYY')), PARTITION pt01022013 VALUES LESS THAN (TO_DATE('01-FEB- 2013', 'DD-MON-YYYY')), PARTITION pt01042013 VALUES LESS THAN (TO_DATE('01-APR- 2013', 'DD-MON-YYYY')), PARTITION pt01062013 VALUES LESS THAN (TO

how to drop partition without dropping data in MySQL?

喜欢而已 提交于 2019-12-03 08:35:58
问题 I have a table like: create table registrations( id int not null auto_increment primary key, name varchar(50), mobile_number varchar(13)) engine=innodb partition by range(id) ( partition p0 values less than (10000), partition p0 values less than (20000), partition p0 values less than max value); Not exactly like above but similar to that.... Now assume that my table has 200000 rows and now I want to remove partitions on the table and reorganize them in accordance to requirement without MAX

What is table partitioning?

人走茶凉 提交于 2019-12-03 08:22:06
问题 In which case we should use table partitioning? 回答1: Partitioning enables tables and indexes or index-organized tables to be subdivided into smaller manageable pieces and these each small piece is called a "partition". For more info: Partitioning in Oracle. What? Why? When? Who? Where? How? 回答2: An example may help. We collected data on a daily basis from a set of 124 grocery stores. Each days data was completely distinct from every other days. We partitioned the data on the date. This

How to partition a MySQL table based on char column?

﹥>﹥吖頭↗ 提交于 2019-12-03 08:06:21
Is it possible to partition based on char column? After reviewing the MySQL 5.1 documentation it appears that only integer types can be used. Is this correct? Or can I use some function to convert the char into an integer? The char field in question contains a unique identifier. Partitioning in MySQL 5.1 can only deal with integer columns ( Source ). You can only use a few partitioning functions on non-integer columns. For example: CREATE TABLE ti (id INT, amount DECIMAL(7,2), tr_date DATE) ENGINE=INNODB PARTITION BY HASH( MONTH(tr_date) ) PARTITIONS 6; You can also use key partitioning in

MAX() and MAX() OVER PARTITION BY produces error 3504 in Teradata Query

一曲冷凌霜 提交于 2019-12-03 07:04:41
I am trying to produce a results table with the last completed course date for each course code, as well as the last completed course code overall for each employee. Below is my query: SELECT employee_number, MAX(course_completion_date) OVER (PARTITION BY course_code) AS max_course_date, MAX(course_completion_date) AS max_date FROM employee_course_completion WHERE course_code IN ('M910303', 'M91301R', 'M91301P') GROUP BY employee_number This query produces the following error: 3504 : Selected non-aggregate values must be part of the associated group If I remove the MAX() OVER (PARTITION BY...)