免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 6944 | 回复: 1
打印 上一主题 下一主题

[数据库] 数据库服务器重启后,首次insert操作很慢 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2017-12-11 18:41 |只看该作者 |倒序浏览
我的oracle数据库中有一张数据表,按照时间进行了分区,根据表空间的使用率,会定期删除老的分区,为防止删分区时的导致的全局索引问题,该表没有创建主键,现在的问题是,每次重启服务器之后的第一个插入操作,会等待50秒,哪怕只插入一条数据,我用sqldeveloper连上测试,并用10046进行了跟踪,trace如下:
********************************************************************************

SQL ID: 06nvwn223659v
Plan Hash: 0
alter session set events '10046 trace name context off'


call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.00       0.00          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        2      0.00       0.00          0          0          0           0

Misses in library cache during parse: 0
Parsing user id: 86  



********************************************************************************

OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        8      0.13       0.26          0          0          0           0
Execute      8      0.63       0.76         17          4         62           1
Fetch        6      0.15       0.41         50      20980          0          15
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total       22      0.92       1.43         67      20984         62          16

Misses in library cache during parse: 7
Misses in library cache during execute: 2

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                       8        0.00          0.00
  SQL*Net message from client                     8       24.35         51.83
  db file sequential read                        67        0.03          0.25


OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse     2516      0.06       0.07          0          0          0           0
Execute   2872      0.50       0.65          4         15         41           8
Fetch     3171      1.10      50.42       2489      14118          0        6462
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total     8559      1.68      51.15       2493      14133         41        6470

Misses in library cache during parse: 42
Misses in library cache during execute: 42

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  db file sequential read                      2493        0.12         49.58
  Disk file operations I/O                       11        0.00          0.00

    8  user  SQL statements in session.
2872  internal SQL statements in session.
2880  SQL statements in session.
********************************************************************************
Trace file: agc_ora_3991.trc
Trace file compatibility: 11.1.0.7
Sort options: default

       1  session in tracefile.
       8  user  SQL statements in trace file.
    2872  internal SQL statements in trace file.
    2880  SQL statements in trace file.
      48  unique SQL statements in trace file.
   70356  lines in trace file.
      95  elapsed seconds in trace file.

我现在想弄明白三件事情:
1.现在这种慢,到底是什么导致的,是因为表没有主键的原因吗?
2.如果主键的原因,那为什么网上有很多帖子说建议分区表不要建主键?
3.为什么只在首次插入的时候出现问题,紧接着第二次插入就非常的快?

希望有高人给予指点,本人对数据库比较小白,多谢~~~

论坛徽章:
0
2 [报告]
发表于 2018-01-04 14:44 |只看该作者
It is a data cache time, you can insert a dummy record and rollback after the database restarted.
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP