in_list 11g优化器改进

测试脚本:
create table audience as
select
        trunc(dbms_random.value(1,13))  month_no
from
        all_objects
where
        rownum <= 1200
;

begin
        dbms_stats.gather_table_stats(
                user,
                'audience',
                cascade => true,
                estimate_percent => null,
                method_opt => 'for all columns size 1'
        );
end;
/
set autotrace traceonly explain

select count(*) from audience
where month_no = 25
;

select count(*) from audience
where month_no in (4, 4)
;

select count(*) from audience
where month_no in (3, 25)
;

select count(*) from audience
where month_no in (3, 25, 26)
;

select count(*) from audience
where month_no in (3, 25, 25, 26)
;

select count(*) from audience
where month_no in (3, 25, null)
;

select count(*) from audience
where month_no in (:b1, :b2, :b3)
;

set autotrace off

现象:
10g
Execution Plan
----------------------------------------------------------
Plan hash value: 3337892515

---------------------------------------------------------------
| Id  | Operation          | Name     | Rows  | Bytes | Cost  |
---------------------------------------------------------------
|   0 | SELECT STATEMENT   |          |     1 |     3 |     2 |
|   1 |  SORT AGGREGATE    |          |     1 |     3 |       |
|*  2 |   TABLE ACCESS FULL| AUDIENCE |     1 |     3 |     2 |
---------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   2 - filter("MONTH_NO"=25)

Note
-----
   - cpu costing is off (consider enabling it)


Execution Plan
----------------------------------------------------------
Plan hash value: 3337892515

---------------------------------------------------------------
| Id  | Operation          | Name     | Rows  | Bytes | Cost  |
---------------------------------------------------------------
|   0 | SELECT STATEMENT   |          |     1 |     3 |     2 |
|   1 |  SORT AGGREGATE    |          |     1 |     3 |       |
|*  2 |   TABLE ACCESS FULL| AUDIENCE |   100 |   300 |     2 |
---------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   2 - filter("MONTH_NO"=4)

Note
-----
   - cpu costing is off (consider enabling it)


Execution Plan
----------------------------------------------------------
Plan hash value: 3337892515

---------------------------------------------------------------
| Id  | Operation          | Name     | Rows  | Bytes | Cost  |
---------------------------------------------------------------
|   0 | SELECT STATEMENT   |          |     1 |     3 |     2 |
|   1 |  SORT AGGREGATE    |          |     1 |     3 |       |
|*  2 |   TABLE ACCESS FULL| AUDIENCE |   100 |   300 |     2 |
---------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   2 - filter("MONTH_NO"=3 OR "MONTH_NO"=25)

Note
-----
   - cpu costing is off (consider enabling it)


Execution Plan
----------------------------------------------------------
Plan hash value: 3337892515

---------------------------------------------------------------
| Id  | Operation          | Name     | Rows  | Bytes | Cost  |
---------------------------------------------------------------
|   0 | SELECT STATEMENT   |          |     1 |     3 |     2 |
|   1 |  SORT AGGREGATE    |          |     1 |     3 |       |
|*  2 |   TABLE ACCESS FULL| AUDIENCE |   101 |   303 |     2 |
---------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   2 - filter("MONTH_NO"=3 OR "MONTH_NO"=25 OR "MONTH_NO"=26)

Note
-----
   - cpu costing is off (consider enabling it)


Execution Plan
----------------------------------------------------------
Plan hash value: 3337892515

---------------------------------------------------------------
| Id  | Operation          | Name     | Rows  | Bytes | Cost  |
---------------------------------------------------------------
|   0 | SELECT STATEMENT   |          |     1 |     3 |     2 |
|   1 |  SORT AGGREGATE    |          |     1 |     3 |       |
|*  2 |   TABLE ACCESS FULL| AUDIENCE |   101 |   303 |     2 |
---------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   2 - filter("MONTH_NO"=3 OR "MONTH_NO"=25 OR "MONTH_NO"=26)

Note
-----
   - cpu costing is off (consider enabling it)


Execution Plan
----------------------------------------------------------
Plan hash value: 3337892515

---------------------------------------------------------------
| Id  | Operation          | Name     | Rows  | Bytes | Cost  |
---------------------------------------------------------------
|   0 | SELECT STATEMENT   |          |     1 |     3 |     2 |
|   1 |  SORT AGGREGATE    |          |     1 |     3 |       |
|*  2 |   TABLE ACCESS FULL| AUDIENCE |   200 |   600 |     2 |
---------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   2 - filter("MONTH_NO"=3 OR "MONTH_NO"=25 OR
              "MONTH_NO"=TO_NUMBER(NULL))

Note
-----
   - cpu costing is off (consider enabling it)


Execution Plan
----------------------------------------------------------
Plan hash value: 3337892515

---------------------------------------------------------------
| Id  | Operation          | Name     | Rows  | Bytes | Cost  |
---------------------------------------------------------------
|   0 | SELECT STATEMENT   |          |     1 |     3 |     2 |
|   1 |  SORT AGGREGATE    |          |     1 |     3 |       |
|*  2 |   TABLE ACCESS FULL| AUDIENCE |   300 |   900 |     2 |
---------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   2 - filter("MONTH_NO"=TO_NUMBER(:B1) OR "MONTH_NO"=TO_NUMBER(:B2) OR
              "MONTH_NO"=TO_NUMBER(:B3))

11g:
Execution Plan
----------------------------------------------------------
Plan hash value: 3337892515

---------------------------------------------------------------
| Id  | Operation          | Name     | Rows  | Bytes | Cost  |
---------------------------------------------------------------
|   0 | SELECT STATEMENT   |          |     1 |     3 |     2 |
|   1 |  SORT AGGREGATE    |          |     1 |     3 |       |
|*  2 |   TABLE ACCESS FULL| AUDIENCE |     1 |     3 |     2 |
---------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   2 - filter("MONTH_NO"=25)

Note
-----
   - cpu costing is off (consider enabling it)


Execution Plan
----------------------------------------------------------
Plan hash value: 3337892515

---------------------------------------------------------------
| Id  | Operation          | Name     | Rows  | Bytes | Cost  |
---------------------------------------------------------------
|   0 | SELECT STATEMENT   |          |     1 |     3 |     2 |
|   1 |  SORT AGGREGATE    |          |     1 |     3 |       |
|*  2 |   TABLE ACCESS FULL| AUDIENCE |   100 |   300 |     2 |
---------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   2 - filter("MONTH_NO"=4)

Note
-----
   - cpu costing is off (consider enabling it)


Execution Plan
----------------------------------------------------------
Plan hash value: 3337892515

---------------------------------------------------------------
| Id  | Operation          | Name     | Rows  | Bytes | Cost  |
---------------------------------------------------------------
|   0 | SELECT STATEMENT   |          |     1 |     3 |     2 |
|   1 |  SORT AGGREGATE    |          |     1 |     3 |       |
|*  2 |   TABLE ACCESS FULL| AUDIENCE |   100 |   300 |     2 |
---------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   2 - filter("MONTH_NO"=3 OR "MONTH_NO"=25)

Note
-----
   - cpu costing is off (consider enabling it)


Execution Plan
----------------------------------------------------------
Plan hash value: 3337892515

---------------------------------------------------------------
| Id  | Operation          | Name     | Rows  | Bytes | Cost  |
---------------------------------------------------------------
|   0 | SELECT STATEMENT   |          |     1 |     3 |     2 |
|   1 |  SORT AGGREGATE    |          |     1 |     3 |       |
|*  2 |   TABLE ACCESS FULL| AUDIENCE |   101 |   303 |     2 |
---------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   2 - filter("MONTH_NO"=3 OR "MONTH_NO"=25 OR "MONTH_NO"=26)

Note
-----
   - cpu costing is off (consider enabling it)


Execution Plan
----------------------------------------------------------
Plan hash value: 3337892515

---------------------------------------------------------------
| Id  | Operation          | Name     | Rows  | Bytes | Cost  |
---------------------------------------------------------------
|   0 | SELECT STATEMENT   |          |     1 |     3 |     2 |
|   1 |  SORT AGGREGATE    |          |     1 |     3 |       |
|*  2 |   TABLE ACCESS FULL| AUDIENCE |   101 |   303 |     2 |
---------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   2 - filter("MONTH_NO"=3 OR "MONTH_NO"=25 OR "MONTH_NO"=26)

Note
-----
   - cpu costing is off (consider enabling it)


Execution Plan
----------------------------------------------------------
Plan hash value: 3337892515

---------------------------------------------------------------
| Id  | Operation          | Name     | Rows  | Bytes | Cost  |
---------------------------------------------------------------
|   0 | SELECT STATEMENT   |          |     1 |     3 |     2 |
|   1 |  SORT AGGREGATE    |          |     1 |     3 |       |
|*  2 |   TABLE ACCESS FULL| AUDIENCE |   100 |   300 |     2 |
---------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   2 - filter("MONTH_NO"=3 OR "MONTH_NO"=25)

Note
-----
   - cpu costing is off (consider enabling it)


Execution Plan
----------------------------------------------------------
Plan hash value: 3337892515

---------------------------------------------------------------
| Id  | Operation          | Name     | Rows  | Bytes | Cost  |
---------------------------------------------------------------
|   0 | SELECT STATEMENT   |          |     1 |     3 |     2 |
|   1 |  SORT AGGREGATE    |          |     1 |     3 |       |
|*  2 |   TABLE ACCESS FULL| AUDIENCE |   300 |   900 |     2 |
---------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   2 - filter("MONTH_NO"=TO_NUMBER(:B1) OR "MONTH_NO"=TO_NUMBER(:B2) OR
              "MONTH_NO"=TO_NUMBER(:B3))

   观测红色字体部分的内容。我们会发现11g中能更精确的计算基数card的值。在刘易斯《基于成本的oracle优化法则中》,他所测试的9i/10g还不能正确计算超出最大最小值界限,只可以很好的处理重复值
我所测试的10g版本已经可以很好的处理最大最小值的问题。11.2.0.3.6中进一步完善了算法,可以更好的处理异常值,但帮定变量还不行

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29033984/viewspace-767028/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/29033984/viewspace-767028/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
帮我优化一下代码 import matplotlib.pyplot as plt from matplotlib.offsetbox import OffsetImage, AnnotationBbox import pandas as pd import tkinter as tk from tkinter import filedialog import csv import numpy as np filepath = filedialog.askopenfilename() readData = pd.read_csv(filepath, encoding = 'gb2312') # 读取csv数据 print(readData) xdata = readData.iloc[:, 2].tolist() # 获取dataFrame中的第3列,并将此转换为list ydata = readData.iloc[:, 3].tolist() # 获取dataFrame中的第4列,并将此转换为list Color_map = { '0x0': 'r', '0x10': 'b', '0x20': 'pink', '0x30': 'm', '0x40': 'm', '0x50': 'm', '0x60': 'g', '0x70': 'orange', '0x80': 'orange', '0x90': 'm', '0xa0': 'b', '0xb0': 'g', '0xc0': 'g', '0xd0': 'orange', '0xe0': 'orange', '0xf0': 'orange', } plt.ion() fig = plt.figure(num = "蓝牙钥匙连接状态", figsize= (10.8,10.8),frameon= True) gs = fig.add_gridspec(1, 1) ax = fig.add_subplot(gs[0, 0]) colors = readData.iloc[:, 1].map(Color_map) plt.title("Connecting Status For Bluetooth Key") #plt.rcParams['figure.figsize']=(15, 15) ax.axis('equal') a,b = (0.,0.) r = [5,10] for r1 in r: theta = np.arange(0,r1*np.pi,0.05) ax.plot(a+r1*np.cos(theta),b+r1*np.sin(theta),linestyle='-.',c = 'darkgrey') ax.spines['bottom'].set_position(('data', 0)) ax.spines['left'].set_position(('data', 0)) ax.spines['right'].set_position(('data', 0)) ax.spines['top'].set_position(('data', 0)) arr_img = plt.imread('D:\\2022\\测试工作\\蓝牙钥匙测试\\定位\\室内定位(v3.6.21).rar-1656500746516.室内定位(v3.6.21)\\车型图2.png') imagebox = OffsetImage(arr_img, zoom=0.3) ab = AnnotationBbox(imagebox, [0, 0],xybox=(0, 0),pad=0) ax.add_artist(ab) ticks = np.arange(-10,10,2) plt.xticks(ticks) plt.yticks(ticks) #plt.figure(figsize=(15,15)) plt.scatter(xdata, ydata, s=150, edgecolors = None, linewidths=0, alpha=0.3,c = colors) # 画散点图,*:r表示点用*表示,颜色为红色 plt.legend() plt.ioff() plt.show() # 画图
最新发布
07-24

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值