Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
e653e4e6
提交
e653e4e6
authored
4月 28, 2017
作者:
Noel Grandin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#426: Support ANALYZE TABLE statement
上级
3c94053d
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
26 行增加
和
5 行删除
+26
-5
help.csv
h2/src/docsrc/help/help.csv
+4
-2
changelog.html
h2/src/docsrc/html/changelog.html
+2
-0
Parser.java
h2/src/main/org/h2/command/Parser.java
+5
-0
Analyze.java
h2/src/main/org/h2/command/ddl/Analyze.java
+15
-3
没有找到文件。
h2/src/docsrc/help/help.csv
浏览文件 @
e653e4e6
...
@@ -415,9 +415,11 @@ ALTER VIEW ADDRESS_VIEW RECOMPILE
...
@@ -415,9 +415,11 @@ ALTER VIEW ADDRESS_VIEW RECOMPILE
"
"
"Commands (DDL)","ANALYZE","
"Commands (DDL)","ANALYZE","
ANALYZE [ SAMPLE_SIZE rowCountInt ]
ANALYZE [
TABLE tableName ] [
SAMPLE_SIZE rowCountInt ]
","
","
Updates the selectivity statistics of all tables. The selectivity is used by the
Updates the selectivity statistics of tables.
If no table name is given, all tables are analyzed.
The selectivity is used by the
cost based optimizer to select the best index for a given query. If no sample
cost based optimizer to select the best index for a given query. If no sample
size is set, up to 10000 rows per table are read. The value 0 means all rows are
size is set, up to 10000 rows per table are read. The value 0 means all rows are
read. The selectivity can be set manually using ALTER TABLE ALTER COLUMN
read. The selectivity can be set manually using ALTER TABLE ALTER COLUMN
...
...
h2/src/docsrc/html/changelog.html
浏览文件 @
e653e4e6
...
@@ -21,6 +21,8 @@ Change Log
...
@@ -21,6 +21,8 @@ Change Log
<h2>
Next Version (unreleased)
</h2>
<h2>
Next Version (unreleased)
</h2>
<ul>
<ul>
<li>
Issue #426: Support ANALYZE TABLE statement
</li>
<li>
Issue #472: Support CREATE SEQUENCE ... ORDER as a NOOP for Oracle compatibility
<li>
Issue #472: Support CREATE SEQUENCE ... ORDER as a NOOP for Oracle compatibility
</li>
</li>
</ul>
</ul>
...
...
h2/src/main/org/h2/command/Parser.java
浏览文件 @
e653e4e6
...
@@ -550,6 +550,11 @@ public class Parser {
...
@@ -550,6 +550,11 @@ public class Parser {
private
Prepared
parseAnalyze
()
{
private
Prepared
parseAnalyze
()
{
Analyze
command
=
new
Analyze
(
session
);
Analyze
command
=
new
Analyze
(
session
);
if
(
readIf
(
"TABLE"
))
{
Table
table
=
readTableOrView
();
command
.
setTable
(
table
);
command
.
setTop
(
readPositiveInt
());
}
if
(
readIf
(
"SAMPLE_SIZE"
))
{
if
(
readIf
(
"SAMPLE_SIZE"
))
{
command
.
setTop
(
readPositiveInt
());
command
.
setTop
(
readPositiveInt
());
}
}
...
...
h2/src/main/org/h2/command/ddl/Analyze.java
浏览文件 @
e653e4e6
...
@@ -22,8 +22,8 @@ import org.h2.value.ValueInt;
...
@@ -22,8 +22,8 @@ import org.h2.value.ValueInt;
import
org.h2.value.ValueNull
;
import
org.h2.value.ValueNull
;
/**
/**
* This class represents the statement
* This class represents the statement
s
* ANALYZE
* ANALYZE
and ANALYZE TABLE
*/
*/
public
class
Analyze
extends
DefineCommand
{
public
class
Analyze
extends
DefineCommand
{
...
@@ -31,20 +31,32 @@ public class Analyze extends DefineCommand {
...
@@ -31,20 +31,32 @@ public class Analyze extends DefineCommand {
* The sample size.
* The sample size.
*/
*/
private
int
sampleRows
;
private
int
sampleRows
;
/**
* used in ANALYZE TABLE...
*/
private
Table
table
;
public
Analyze
(
Session
session
)
{
public
Analyze
(
Session
session
)
{
super
(
session
);
super
(
session
);
sampleRows
=
session
.
getDatabase
().
getSettings
().
analyzeSample
;
sampleRows
=
session
.
getDatabase
().
getSettings
().
analyzeSample
;
}
}
public
void
setTable
(
Table
table
)
{
this
.
table
=
table
;
}
@Override
@Override
public
int
update
()
{
public
int
update
()
{
session
.
commit
(
true
);
session
.
commit
(
true
);
session
.
getUser
().
checkAdmin
();
session
.
getUser
().
checkAdmin
();
Database
db
=
session
.
getDatabase
();
Database
db
=
session
.
getDatabase
();
if
(
table
!=
null
)
{
analyzeTable
(
session
,
table
,
sampleRows
,
true
);
}
else
{
for
(
Table
table
:
db
.
getAllTablesAndViews
(
false
))
{
for
(
Table
table
:
db
.
getAllTablesAndViews
(
false
))
{
analyzeTable
(
session
,
table
,
sampleRows
,
true
);
analyzeTable
(
session
,
table
,
sampleRows
,
true
);
}
}
}
return
0
;
return
0
;
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论