database-partitioning

how to partition a table by datetime column?

╄→гoц情女王★ 提交于 2019-12-17 15:34:50
问题 I want to partition a mysql table by datetime column. One day a partition.The create table scripts is like this: CREATE TABLE raw_log_2011_4 ( id bigint(20) NOT NULL AUTO_INCREMENT, logid char(16) NOT NULL, tid char(16) NOT NULL, reporterip char(46) DEFAULT NULL, ftime datetime DEFAULT NULL, KEY id (id) ) ENGINE=InnoDB AUTO_INCREMENT=286802795 DEFAULT CHARSET=utf8 PARTITION BY hash (day(ftime)) partitions 31; But when I select data of some day.It could not locate the partition.The select

Improving DELETE and INSERT times on a large table that has an index structure

元气小坏坏 提交于 2019-12-14 03:50:48
问题 Our application manages a table containing a per-user set of rows that is the result of a computationally-intensive query. Storing this result in a table seems a good way of speeding up further calculations. The structure of that table is basically the following: CREATE TABLE per_user_result_set ( user_login VARCHAR2(N) , result_set_item_id VARCHAR2(M) , CONSTRAINT result_set_pk PRIMARY KEY(user_login, result_set_item_id) ) ; A typical user of our application will have this result set

Is there a performance difference in using a GROUP BY with MAX() as the aggregate vs ROW_NUMBER over partition by?

£可爱£侵袭症+ 提交于 2019-12-14 03:45:43
问题 Is there a performance difference between the following 2 queries, and if so, then which one is better?: select q.id, q.name from( select id, name, row_number over (partition by name order by id desc) as row_num from table ) q where q.row_num = 1 versus select max(id) , name from table group by name (The result set should be the same) This is assuming that no indexes are set. UPDATE: I tested this, and the group by was faster. 回答1: The group by should be faster. The row number has to assign a

How does one do a SQL select over multiple partitions?

痴心易碎 提交于 2019-12-13 11:40:27
问题 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 ); 回答1: 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

Drop oldest partition automatically in oracle 11G

血红的双手。 提交于 2019-12-12 11:59:23
问题 I have a requirement to drop partition from an interval partitioned table, if the partition is older than three months. Is there a oracle utility/function to do this? Or if not, how to implement this? Please guide me. Database version: Oracle 11G 回答1: I don't know of any oracle utility or function to do this. You can find the information you need to write your own program to do this in the DBA_TAB_PARTITIONS or ALL_TAB_PARTITIONS views, similar to the following: SELECT TABLE_OWNER, TABLE_NAME

Partitioning and Sequence Increment

。_饼干妹妹 提交于 2019-12-12 00:17:19
问题 I have table call it scdr_buz and have partitioned it on monthly basis, I have created trigger on insert which take care of upsert and create table if not present then upsert. I have sequence i_buz_scdr sequence with 1 increment but it's behavior while added rows in random not increment of 1. here is code of my trigger: CREATE OR REPLACE FUNCTION tbl_scdr_buz_insert_trigger() RETURNS TRIGGER AS $$ BEGIN EXECUTE 'UPDATE scdr_buz_'|| to_char(NEW.start_time, 'YYYY_MM') ||' sc SET c_total_calls =

Range partition table creation with large number of paritions

蓝咒 提交于 2019-12-11 16:39:28
问题 i have to create an range partitioned table with two hundred partitions. for eg: CREATE TABLE emp ( empno NUMBER(4), ename VARCHAR2(30), sal NUMBER ) PARTITION BY RANGE(empno) ( partition e1 values less than (1000) , partition e2 values less than (2000) , ... partition e200 values less than (MAXVALUE) ); Is there a way to specify the range interval without writing two hundred lines for just specifing the range? 回答1: CREATE TABLE emp ( empno NUMBER(4), ename VARCHAR2(30), sal NUMBER )

How to backup a partitioned table in PostgresSQL 10

那年仲夏 提交于 2019-12-11 08:03:27
问题 Is it possible to make a backup of a specific partitioned table with PostgreSQL 10? When using: sudo pg_dump -Fc -f "/home/schema.backup" -t schema.partitioned_table dbname I am only getting the skeleton of the base table, without any values and without any partitions. I also couldn't find anything in the extensive documentation. 回答1: You'd have to use -t for all partitions. This is probably a consequence of the design decision to have partitions visible as individual tables on the SQL level.

Table inheritance: Enforcing unique constraints across partitions?

☆樱花仙子☆ 提交于 2019-12-11 07:14:10
问题 I have a table that I would like to partition, but I don't know how to deal with the uniqueness constraints. Is it possible to create a unique constraint across multiple child tables? 回答1: No, this is not currently possible. The best you can do is to create a trigger that does the verification manually. 来源: https://stackoverflow.com/questions/936818/table-inheritance-enforcing-unique-constraints-across-partitions

mysql partitioning

♀尐吖头ヾ 提交于 2019-12-11 03:08:26
问题 just want to verify that database partition is implemented only at the database level, when we query a partitioned table, we still do our normal query, nothing special with our queries, the optimization is performed automatically when parsing the query, is that correct? e.g. we have a table called 'address' with a column called 'country_code' and 'city'. so if i want to get all the addresses in New York, US, normally i wound do something like this: select * from address where country_code =