甘肃PON数据库分区列范围查询优化

查询慢的SQL:

  1. with p as(
  2. select np.nodecode , np.nodename, d.deviceid, d.devicename, d.loopaddress, p.respara, p.rxcrcerror, p.txcrcerror
  3. from perf_t_ponport p,device d, node c,node np
  4. where p.resid = d.deviceid
  5. and d.nodecode = c.nodecode
  6. and c.citynodecode = np.nodecode
  7. and c.nodecode in (SELECT S.NODECODE FROM SINGLEUSERNODEAUTH S WHERE S.NETUSERID = ‘admin‘ AND S.AUTHTYPE = ‘VIEW‘)
  8. and d.changetype = 0
  9. and p.coltime between trunc(sysdate-1,‘dd‘) and trunc(sysdate,‘dd‘)
  10. and p.rxcrcerror is not null
  11. and p.rxcrcerror >0
  12. order by p.rxcrcerror desc
  13. )
  14. select *
  15. from p
  16. where rownum <=10

这个SQL执行花费了1分钟24秒,需要优化。

查看执行计划:

  1. SQL> explain plan for with p as(
  2. 2 select np.nodecode , np.nodename, d.deviceid, d.devicename, d.loopaddress, p.respara, p.rx
  3. crcerror, p.txcrcerror
  4. 3 from perf_t_ponport p,device d, node c,node np
  5. 4 where p.resid = d.deviceid
  6. 5 and d.nodecode = c.nodecode
  7. 6 and c.citynodecode = np.nodecode
  8. 7 and c.nodecode in (SELECT S.NODECODE FROM SINGLEUSERNODEAUTH S WHERE S.NETUSERID = ‘adm
  9. in‘ AND S.AUTHTYPE = ‘VIEW‘)
  10. 8 and d.changetype = 0
  11. 9 and p.coltime between trunc(sysdate-1,‘dd‘) and trunc(sysdate,‘dd‘)
  12. 10 and p.rxcrcerror is not null
  13. 11 and p.rxcrcerror >0
  14. 12 order by p.rxcrcerror desc
  15. 13 )
  16. 14 select *
  17. 15 from p
  18. 16 where rownum <=10
  19. 17 ;
  20. 已解释。
  21. SQL> select * from table(dbms_xplan.display);
  22. PLAN_TABLE_OUTPUT
  23. ----------------------------------------------------------------------------------------------------
  24. Plan hash value: 733587010
  25. ----------------------------------------------------------------------------------------------------
  26. | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |
  27. ----------------------------------------------------------------------------------------------------
  28. | 0 | SELECT STATEMENT | | 10 | 3430 | 1125K (19)| 03:45:09 | | |
  29. |* 1 | COUNT STOPKEY | | | | | | | |
  30. | 2 | VIEW | | 133 | 45619 | 1125K (19)| 03:45:09 | | |
  31. |* 3 | SORT ORDER BY STOPKEY | | 133 | 22743 | 1125K (19)| 03:45:09 | | |
  32. |* 4 | FILTER | | | | | | | |
  33. |* 5 | HASH JOIN | | 133 | 22743 | 1125K (19)| 03:45:09 | | |
  34. |* 6 | HASH JOIN SEMI | | 133 | 19950 | 1125K (19)| 03:45:08 | | |
  35. |* 7 | HASH JOIN | | 219 | 28251 | 1125K (19)| 03:45:08 | | |
  36. | 8 | NESTED LOOPS | | 219 | 25185 | 1125K (19)| 03:45:08 | | |
  37. | 9 | PARTITION RANGE ITERATOR | | 219 | 10074 | 1125K (19)| 03:45:03 | KEY | KEY |
  38. |* 10 | TABLE ACCESS FULL | PERF_T_PONPORT | 219 | 10074 | 1125K (19)| 03:45:03 | KEY | KE
  39. | 11 | TABLE ACCESS BY INDEX ROWID| DEVICE | 1 | 69 | 2 (0)| 00:00:01 | |
  40. |* 12 | INDEX UNIQUE SCAN | PK_DEVICE | 1 | | 1 (0)| 00:00:01 | |
  41. | 13 | TABLE ACCESS FULL | NODE | 1214 | 16996 | 8 (0)| 00:00:01 | | |
  42. |* 14 | INDEX RANGE SCAN | SYS_C00543203 | 1167 | 24507 | 10 (0)| 00:00:01 | |
  43. | 15 | TABLE ACCESS FULL | NODE | 1214 | 25494 | 8 (0)| 00:00:01 | |
  44. ----------------------------------------------------------------------------------------------------
  45. Predicate Information (identified by operation id):
  46. ---------------------------------------------------
  47. 1 - filter(ROWNUM<=10)
  48. 3 - filter(ROWNUM<=10)
  49. 4 - filter(TRUNC([email protected]!-1,‘fmdd‘)<=TRUNC([email protected]!,‘fmdd‘))
  50. 5 - access("C"."CITYNODECODE"="NP"."NODECODE")
  51. 6 - access("C"."NODECODE"="S"."NODECODE")
  52. 7 - access("D"."NODECODE"="C"."NODECODE")
  53. 10 - filter("P"."RXCRCERROR" IS NOT NULL AND "P"."RXCRCERROR">0 AND
  54. "P"."COLTIME">=TRUNC([email protected]!-1,‘fmdd‘) AND "P"."COLTIME"<=TRUNC([email protected]!,‘fmdd‘))
  55. 12 - access("P"."RESID"="D"."DEVICEID" AND "D"."CHANGETYPE"=0)
  56. 14 - access("S"."NETUSERID"=‘admin‘ AND "S"."AUTHTYPE"=‘VIEW‘)
  57. 已选择36行。

查看执行计划:id为4的filter过滤条件为filter(TRUNC([email protected]!-1,‘fmdd‘)<=TRUNC([email protected]!,‘fmdd‘))。 查看id为9的执行计划访问分区的方式为:PARTITION RANGE ITERATOR。 说明分区表PERF_T_PONPORT的分区列的条件导致了性能压力。

coltime的列都是yyyy/mm/dd的格式,因此可以将PERF_T_PONPORT的分区列的条件条件改写为:(p.coltime =trunc(sysdate-1,‘dd‘) or p.coltime =trunc(sysdate,‘dd‘) )。

改写后的语句:

  1. with p as(
  2. select np.nodecode , np.nodename, d.deviceid, d.devicename, d.loopaddress, p.respara, p.rxcrcerror, p.txcrcerror
  3. from perf_t_ponport p,device d, node c,node np
  4. where p.resid = d.deviceid
  5. and d.nodecode = c.nodecode
  6. and c.citynodecode = np.nodecode
  7. and d.changetype = 0
  8. and c.nodecode in (SELECT S.NODECODE FROM SINGLEUSERNODEAUTH S WHERE S.NETUSERID = ‘admin‘ AND S.AUTHTYPE = ‘VIEW‘)
  9. and (p.coltime =trunc(sysdate-1,‘dd‘) or p.coltime =trunc(sysdate,‘dd‘) )
  10. and p.rxcrcerror is not null
  11. and p.rxcrcerror >0
  12. order by p.rxcrcerror desc
  13. )
  14. select *
  15. from p
  16. where rownum <=10;

改写后的执行计划:

  1. SQL> explain plan for with p as(
  2. 2 select np.nodecode , np.nodename, d.deviceid, d.devicename, d.loopaddress, p.respara, p.r
  3. xcrcerror, p.txcrcerror
  4. 3 from perf_t_ponport p,device d, node c,node np
  5. 4 where p.resid = d.deviceid
  6. 5 and d.nodecode = c.nodecode
  7. 6 and c.citynodecode = np.nodecode
  8. 7 and d.changetype = 0
  9. 8 and c.nodecode in (SELECT S.NODECODE FROM SINGLEUSERNODEAUTH S WHERE S.NETUSERID = ‘admin
  10. ‘ AND S.AUTHTYPE = ‘VIEW‘)
  11. 9 and (p.coltime =trunc(sysdate-1,‘dd‘) or p.coltime =trunc(sysdate,‘dd‘) )
  12. 10 and p.rxcrcerror is not null
  13. 11 and p.rxcrcerror >0
  14. 12 order by p.rxcrcerror desc
  15. 13 )
  16. 14 select *
  17. 15 from p
  18. 16 where rownum <=10;
  19. 已解释。
  20. SQL>
  21. SQL> select * from table(dbms_xplan.display);
  22. PLAN_TABLE_OUTPUT
  23. ----------------------------------------------------------------------------------------------------
  24. Plan hash value: 2287749996
  25. ----------------------------------------------------------------------------------------------------
  26. | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |
  27. ----------------------------------------------------------------------------------------------------
  28. | 0 | SELECT STATEMENT | | 10 | 3430 | 915 (2)| 00:00:11 | | |
  29. |* 1 | COUNT STOPKEY | | | | | | | |
  30. | 2 | VIEW | | 266 | 91238 | 915 (2)| 00:00:11 | | |
  31. |* 3 | SORT ORDER BY STOPKEY | | 266 | 45486 | 915 (2)| 00:00:11 | | |
  32. |* 4 | HASH JOIN | | 266 | 45486 | 915 (2)| 00:00:11 | | |
  33. | 5 | TABLE ACCESS FULL | NODE | 1214 | 25494 | 8 (0)| 00:00:01 | | |
  34. |* 6 | HASH JOIN RIGHT SEMI | | 267 | 40050 | 905 (2)| 00:00:11 | | |
  35. |* 7 | INDEX RANGE SCAN | SYS_C00543203 | 1167 | 24507 | 10 (0)| 00:00:01 | |
  36. |* 8 | HASH JOIN | | 437 | 56373 | 895 (2)| 00:00:11 | | |
  37. | 9 | TABLE ACCESS FULL | NODE | 1214 | 16996 | 8 (0)| 00:00:01 | | |
  38. | 10 | NESTED LOOPS | | 437 | 50255 | 885 (2)| 00:00:11 | | |
  39. | 11 | PARTITION RANGE INLIST | | 437 | 20102 | 2 (0)| 00:00:01 |KEY(I) |KEY(I) |
  40. |* 12 | TABLE ACCESS FULL | PERF_T_PONPORT | 437 | 20102 | 2 (0)| 00:00:01 |KEY(I) |KEY(I)
  41. | 13 | TABLE ACCESS BY INDEX ROWID| DEVICE | 1 | 69 | 2 (0)| 00:00:01 | | |
  42. |* 14 | INDEX UNIQUE SCAN | PK_DEVICE | 1 | | 1 (0)| 00:00:01 | | |
  43. ----------------------------------------------------------------------------------------------------
  44. Predicate Information (identified by operation id):
  45. ---------------------------------------------------
  46. 1 - filter(ROWNUM<=10)
  47. 3 - filter(ROWNUM<=10)
  48. 4 - access("C"."CITYNODECODE"="NP"."NODECODE")
  49. 6 - access("C"."NODECODE"="S"."NODECODE")
  50. 7 - access("S"."NETUSERID"=‘admin‘ AND "S"."AUTHTYPE"=‘VIEW‘)
  51. 8 - access("D"."NODECODE"="C"."NODECODE")
  52. 12 - filter("P"."RXCRCERROR" IS NOT NULL AND "P"."RXCRCERROR">0 AND
  53. ("P"."COLTIME"=TRUNC([email protected]!-1,‘fmdd‘) OR "P"."COLTIME"=TRUNC([email protected]!,‘fmdd‘)))
  54. 14 - access("P"."RESID"="D"."DEVICEID" AND "D"."CHANGETYPE"=0)
  55. 已选择34行。

改写后, SQL执行花了9秒钟, 性能提升了9倍。改写后的SQL消除了filter, 访问分区的方式为 PARTITION RANGE INLIST 。

关于几种分区访问的方式:

范围分区:

1、PARTITION RANGE ITERATOR

  1. SQL> explain plan for select * from perf_t_ponport p where p.coltime <trunc(sysdate,‘dd‘);
  2. 已解释。
  3. SQL> select * from table(dbms_xplan.display);
  4. PLAN_TABLE_OUTPUT
  5. ----------------------------------------------------------------------------------------------------
  6. Plan hash value: 4015217925
  7. ----------------------------------------------------------------------------------------------------
  8. | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |
  9. ----------------------------------------------------------------------------------------------------
  10. | 0 | SELECT STATEMENT | | 100 | 4600 | 2 (0)| 00:00:01 | | |
  11. | 1 | PARTITION RANGE ITERATOR| | 100 | 4600 | 2 (0)| 00:00:01 | 1 | KEY |
  12. |* 2 | TABLE ACCESS FULL | PERF_T_PONPORT | 100 | 4600 | 2 (0)| 00:00:01 | 1 | KEY |
  13. ----------------------------------------------------------------------------------------------------
  14. Predicate Information (identified by operation id):
  15. ---------------------------------------------------
  16. 2 - filter("P"."COLTIME"<TRUNC([email protected]!,‘fmdd‘))
  17. 已选择14行。
  1. SQL> explain plan for select * from perf_t_ponport p where p.coltime > trunc(sysdate-1,‘dd‘) and p.
  2. coltime <trunc(sysdate,‘dd‘);
  3. 已解释。
  4. SQL> select * from table(dbms_xplan.display);
  5. PLAN_TABLE_OUTPUT
  6. ----------------------------------------------------------------------------------------------------
  7. Plan hash value: 1162550374
  8. ----------------------------------------------------------------------------------------------------
  9. | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |
  10. ----------------------------------------------------------------------------------------------------
  11. | 0 | SELECT STATEMENT | | 100 | 4600 | 1637 (37)| 00:00:20 | | |
  12. |* 1 | FILTER | | | | | | | |
  13. | 2 | PARTITION RANGE ITERATOR| | 100 | 4600 | 1637 (37)| 00:00:20 | KEY | KEY |
  14. |* 3 | TABLE ACCESS FULL | PERF_T_PONPORT | 100 | 4600 | 1637 (37)| 00:00:20 | KEY |
  15. ----------------------------------------------------------------------------------------------------
  16. Predicate Information (identified by operation id):
  17. ---------------------------------------------------
  18. 1 - filter(TRUNC([email protected]!-1,‘fmdd‘)<TRUNC([email protected]!,‘fmdd‘))
  19. 3 - filter("P"."COLTIME">TRUNC([email protected]!-1,‘fmdd‘) AND "P"."COLTIME"<TRUNC([email protected]!,‘fmdd‘))
  20. 已选择16行。

PARTITION RANGE ITERATOR是通过连续的分区迭代来获取数据。

2、PARTITION RANGE SINGLE

  1. SQL> explain plan for select * from perf_t_ponport partition(P_20170307) p;
  2. 已解释。
  3. SQL> select * from table(dbms_xplan.display);
  4. PLAN_TABLE_OUTPUT
  5. ----------------------------------------------------------------------------------------------------
  6. Plan hash value: 1021280532
  7. ----------------------------------------------------------------------------------------------------
  8. | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |
  9. ----------------------------------------------------------------------------------------------------
  10. | 0 | SELECT STATEMENT | | 100 | 4600 | 2 (0)| 00:00:01 | | |
  11. | 1 | PARTITION RANGE SINGLE| | 100 | 4600 | 2 (0)| 00:00:01 | 85 | 85 |
  12. | 2 | TABLE ACCESS FULL | PERF_T_PONPORT | 100 | 4600 | 2 (0)| 00:00:01 | 85 |
  13. ----------------------------------------------------------------------------------------------------
  14. 已选择9行。
  1. SQL> explain plan for select * from perf_t_ponport p where p.coltime = trunc(sysdate-1,‘dd‘) and p.
  2. coltime <trunc(sysdate,‘dd‘);
  3. 已解释。
  4. SQL> select * from table(dbms_xplan.display);
  5. PLAN_TABLE_OUTPUT
  6. ----------------------------------------------------------------------------------------------------
  7. Plan hash value: 506920385
  8. ----------------------------------------------------------------------------------------------------
  9. | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |
  10. ----------------------------------------------------------------------------------------------------
  11. | 0 | SELECT STATEMENT | | 100 | 4600 | 8 (25)| 00:00:01 | | |
  12. |* 1 | FILTER | | | | | | | |
  13. | 2 | PARTITION RANGE SINGLE| | 100 | 4600 | 8 (25)| 00:00:01 | KEY | KEY |
  14. |* 3 | TABLE ACCESS FULL | PERF_T_PONPORT | 100 | 4600 | 8 (25)| 00:00:01 | KEY | KE
  15. ----------------------------------------------------------------------------------------------------
  16. Predicate Information (identified by operation id):
  17. ---------------------------------------------------
  18. 1 - filter(TRUNC([email protected]!-1,‘fmdd‘)<TRUNC([email protected]!,‘fmdd‘))
  19. 3 - filter("P"."COLTIME"=TRUNC([email protected]!-1,‘fmdd‘) AND "P"."COLTIME"<TRUNC([email protected]!,‘fmdd‘))
  20. 已选择16行。

PARTITION RANGE SINGLE只扫描一个分区。

3、PARTITION RANGE INLIST

  1. SQL> explain plan for select * from perf_t_ponport p where p.coltime = trunc(sysdate-1,‘dd‘) or p.c
  2. oltime = trunc(sysdate,‘dd‘);
  3. 已解释。
  4. SQL> select * from table(dbms_xplan.display);
  5. PLAN_TABLE_OUTPUT
  6. ----------------------------------------------------------------------------------------------------
  7. Plan hash value: 2473962793
  8. ----------------------------------------------------------------------------------------------------
  9. | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |
  10. ----------------------------------------------------------------------------------------------------
  11. | 0 | SELECT STATEMENT | | 100 | 4600 | 2 (0)| 00:00:01 | | |
  12. | 1 | PARTITION RANGE INLIST| | 100 | 4600 | 2 (0)| 00:00:01 |KEY(I) |KEY(I) |
  13. |* 2 | TABLE ACCESS FULL | PERF_T_PONPORT | 100 | 4600 | 2 (0)| 00:00:01 |KEY(I) |KEY(I)
  14. ----------------------------------------------------------------------------------------------------
  15. Predicate Information (identified by operation id):
  16. ---------------------------------------------------
  17. 2 - filter("P"."COLTIME"=TRUNC([email protected]!-1,‘fmdd‘) OR "P"."COLTIME"=TRUNC([email protected]!,‘fmdd‘))
  18. 已选择14行。

上面的KEY(I)就是KEY(INLIST)的意思。PARTITION RANGE INLIST无法通过Pstart和Pstop看出分区的起始和结束位置 。

4、ARTITION RANGE ALL和PARTITION RANGE OR

  1. SQL> explain plan for select * from perf_t_ponport p where p.coltime >trunc(sysdate-1,‘dd‘) or p.c
  2. oltime < trunc(sysdate-5,‘dd‘);
  3. 已解释。
  4. SQL> select * from table(dbms_xplan.display);
  5. PLAN_TABLE_OUTPUT
  6. ----------------------------------------------------------------------------------------------------
  7. Plan hash value: 3647984539
  8. ----------------------------------------------------------------------------------------------------
  9. | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |
  10. ----------------------------------------------------------------------------------------------------
  11. | 0 | SELECT STATEMENT | | 100 | 4600 | 2 (0)| 00:00:01 | | |
  12. | 1 | PARTITION RANGE ALL| | 100 | 4600 | 2 (0)| 00:00:01 | 1 | 101 |
  13. |* 2 | TABLE ACCESS FULL | PERF_T_PONPORT | 100 | 4600 | 2 (0)| 00:00:01 | 1 | 101 |
  14. ----------------------------------------------------------------------------------------------------
  15. Predicate Information (identified by operation id):
  16. ---------------------------------------------------
  17. 2 - filter("P"."COLTIME"<TRUNC([email protected]!-5,‘fmdd‘) OR
  18. "P"."COLTIME">TRUNC([email protected]!-1,‘fmdd‘))
  19. 已选择15行。

ARTITION RANGE ALL是全分区扫描, 上面是在oracle 10g环境测试, 在Oracle 11g环境下,分区扫描方式为:PARTITION RANGE OR, 可以看出11g对这种分区查询条件扫描方式做了优化。

  1. SQL> explain plan for select * from perf_t_ponport p where p.coltime >trunc(sysdate-1,‘dd‘) or p.c
  2. oltime < trunc(sysdate-5,‘dd‘);
  3. 已解释。
  4. SQL> select * from table(dbms_xplan.display);
  5. PLAN_TABLE_OUTPUT
  6. ----------------------------------------------------------------------------------------------------
  7. Plan hash value: 470656424
  8. ----------------------------------------------------------------------------------------------------
  9. | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |
  10. ----------------------------------------------------------------------------------------------------
  11. | 0 | SELECT STATEMENT | | 1512M| 67G| 3783K (3)| 12:36:37 | | |
  12. | 1 | PARTITION RANGE OR| | 1512M| 67G| 3783K (3)| 12:36:37 |KEY(OR)|KEY(OR)|
  13. |* 2 | TABLE ACCESS FULL| PERF_T_PONPORT | 1512M| 67G| 3783K (3)| 12:36:37 |KEY(OR)|KEY(OR)|
  14. ----------------------------------------------------------------------------------------------------
  15. Predicate Information (identified by operation id):
  16. ---------------------------------------------------
  17. 2 - filter("P"."COLTIME"<TRUNC([email protected]!-5,‘fmdd‘) OR
  18. "P"."COLTIME">TRUNC([email protected]!-1,‘fmdd‘))
  19. Note
  20. -----
  21. - ‘PLAN_TABLE‘ is old version
  22. 已选择19行。
时间: 2024-11-15 10:04:05

甘肃PON数据库分区列范围查询优化的相关文章

MySql学习(六) —— 数据库优化理论(二) —— 查询优化技术

逻辑查询优化包括的技术 1)子查询优化  2)视图重写  3)等价谓词重写  4)条件简化  5)外连接消除  6)嵌套连接消除  7)连接消除  8)语义优化 9)非SPJ优化 一.子查询优化 1. 什么是子查询:当一个查询是另一个查询的子部分时,称之为子查询. 2. 查询的子部分,包含的情况: a) 目标列位置:子查询如果位于目标列,则只能是标量子查询,否则数据库可能返回类似“错误:子查询只能返回一个字段 ( [Err] 1242 - Subquery returns more than 1

mysql数据库分区功能及实例详解

分区听起来怎么感觉是硬盘呀,对没错除了硬盘可以分区数据库现在也支持分区了,分区可以解决大数据量的处理问题,下面一起来看一个mysql数据库分区功能及实例详解 一,什么是数据库分区 前段时间写过一篇关于mysql分表的的文章,下面来说一下什么是数据库分区,以mysql为例.mysql数据库中的数据是以文件的形势存在磁盘上的,默认放在/mysql/data下面(可以通过my.cnf中的datadir来查看),一张表主要对应着三个文件,一个是frm存放表结构的,一个是myd存放表数据的,一个是myi存

Atitit.数据库分区的设计&#160;attilax&#160;&#160;总结

Atitit.数据库分区的设计 attilax  总结 1. 分区就是分门别类的文件夹 (what)1 2. 分区的好处(y)1 3. 分区原则(要不要分区,何时分区)how2 4. 主要的分表类型有range,list,hash,key等2 5. 水平分区(Horizontal Partitioning) 垂直分区(Vertical Partitioning)3 6. 分区的操作4 7. 分区理论  并行数据库的体系结构4 8. 参考7 1. 分区就是分门别类的文件夹 (what) 分区的原理

MySQL数据库分区的概念与2大好处(1)

我们大家都知道通过MySQL数据库分区(Partition)可以提升MySQL数据库的性能,那么到底什么是MySQL数据库分区呢?以及其实际应用的好处的表现有哪些呢?以下的文章就是对这些内容的描述. 什么是数据库分区? 数据库分区是一种物理数据库设计技术,DBA和数据库建模人员对其相当熟悉.虽然分区技术可以实现很多效果,但其主要目的是为了在特定的SQL操作 中减少数据读写的总量以缩减响应时间. 分区主要有两种形式://这里一定要注意行和列的概念(row是行,column是列) 水平分区(Hori

关于数据库分区后的几个查询和补充

--查看分区及分区范围的情况 select * from sys.partitions where object_id = object_id('SecureUsbLog'); select * from sys.partition_range_values; --查看分区架构情况 select * from sys.partition_schemes; --查看某一特定分区列值属于哪个分区 select M2.$partition.Part_mediasec_func('20150325')

处理Zabbixl历史数据库解决办法三---使用平民软件的OneProxy来为Zabbix数据库分区和扩容

一 应用场景描述 二 OneProxy介绍及使用 三 使用OneProxy来为Zabbix数据库分区和扩容 参考文档:

数据库一列多行转一行多列

如题: select max(case when name='1' then [temp] else null end) as temp1 , max(case when name='2' then [temp] else null end) as temp2, max(case when name='3' then [temp] else null end) as temp3 from historyt group by time 数据库一列多行转一行多列,布布扣,bubuko.com

sqlserver分区视图中分区列的规则

分区列规则 分区列存在于每个成员表上,并且通过 CHECK 约束标识特定表中的可用数据.分区列必须遵守如下规则: 每个基表都拥有键值由 CHECK 约束所强制的分区列.每个表的 CHECK 约束的键范围与其它任何表互不重叠.任何分区列的给定值必须只能映射到一个表.CHECK 约束只能使用以下运算符:BETWEEN.AND.OR.<.<=.>.>=.=. 分区列不能是标识.默认或 timestamp 列. 在视图中,分区列必须位于每个 SELECT 语句的选择列表中相同的序号位置处.

sql2008 计划自动创建数据库分区【转】

本文转自:http://jingyan.baidu.com/article/6b97984d9a26ec1ca3b0bf77.html sql2008 计划自动创建数据库分区 固定增量的数据,自动创建分区作业. 步骤一:创建分区的计划任务 打开MsSQL2008,找到作业该项,如果打不开或者SQL Server代理是未启动状态,请先在windows服务中启动SQL Server代理(参考图片),   右击MsSQL2008对象资源管理器中的作业,选择新建作业,输入该作业你想用的名称,类别不用管,