~vkolesnikov/pbxt/pbxt-07-diskfull

« back to all changes in this revision

Viewing changes to pbxt/mysql-test-update/mysql-test/r/analyse.result

  • Committer: paul-mccullagh
  • Date: 2006-10-23 09:14:04 UTC
  • Revision ID: paul-mccullagh-918861e03d351978a9541168a96e58cc826734ee
Initial import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
drop table if exists t1,t2;
 
2
create table t1 (i int, j int, empty_string char(10), bool char(1), d date);
 
3
insert into t1 values (1,2,"","Y","2002-03-03"), (3,4,"","N","2002-03-04"), (5,6,"","Y","2002-03-04"), (7,8,"","N","2002-03-05");
 
4
select count(*) from t1 procedure analyse();
 
5
Field_name      Min_value       Max_value       Min_length      Max_length      Empties_or_zeros        Nulls   Avg_value_or_avg_length Std     Optimal_fieldtype
 
6
count(*)        4       4       1       1       0       0       4.0000  0.0000  ENUM('4') NOT NULL
 
7
select * from t1 procedure analyse();
 
8
Field_name      Min_value       Max_value       Min_length      Max_length      Empties_or_zeros        Nulls   Avg_value_or_avg_length Std     Optimal_fieldtype
 
9
test.t1.i       1       7       1       1       0       0       4.0000  2.2361  ENUM('1','3','5','7') NOT NULL
 
10
test.t1.j       2       8       1       1       0       0       5.0000  2.2361  ENUM('2','4','6','8') NOT NULL
 
11
test.t1.empty_string                    0       0       4       0       0.0000  NULL    CHAR(0) NOT NULL
 
12
test.t1.bool    N       Y       1       1       0       0       1.0000  NULL    ENUM('N','Y') NOT NULL
 
13
test.t1.d       2002-03-03      2002-03-05      10      10      0       0       10.0000 NULL    ENUM('2002-03-03','2002-03-04','2002-03-05') NOT NULL
 
14
select * from t1 procedure analyse(2);
 
15
Field_name      Min_value       Max_value       Min_length      Max_length      Empties_or_zeros        Nulls   Avg_value_or_avg_length Std     Optimal_fieldtype
 
16
test.t1.i       1       7       1       1       0       0       4.0000  2.2361  TINYINT(1) UNSIGNED NOT NULL
 
17
test.t1.j       2       8       1       1       0       0       5.0000  2.2361  TINYINT(1) UNSIGNED NOT NULL
 
18
test.t1.empty_string                    0       0       4       0       0.0000  NULL    CHAR(0) NOT NULL
 
19
test.t1.bool    N       Y       1       1       0       0       1.0000  NULL    ENUM('N','Y') NOT NULL
 
20
test.t1.d       2002-03-03      2002-03-05      10      10      0       0       10.0000 NULL    ENUM('2002-03-03','2002-03-04','2002-03-05') NOT NULL
 
21
create table t2 select * from t1 procedure analyse();
 
22
select * from t2;
 
23
Field_name      Min_value       Max_value       Min_length      Max_length      Empties_or_zeros        Nulls   Avg_value_or_avg_length Std     Optimal_fieldtype
 
24
test.t1.i       1       7       1       1       0       0       4.0000  2.2361  ENUM('1','3','5','7') NOT NULL
 
25
test.t1.j       2       8       1       1       0       0       5.0000  2.2361  ENUM('2','4','6','8') NOT NULL
 
26
test.t1.empty_string                    0       0       4       0       0.0000  NULL    CHAR(0) NOT NULL
 
27
test.t1.bool    N       Y       1       1       0       0       1.0000  NULL    ENUM('N','Y') NOT NULL
 
28
test.t1.d       2002-03-03      2002-03-05      10      10      0       0       10.0000 NULL    ENUM('2002-03-03','2002-03-04','2002-03-05') NOT NULL
 
29
drop table t1,t2;
 
30
EXPLAIN SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE();
 
31
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
32
1       PRIMARY <derived2>      system  NULL    NULL    NULL    NULL    1       
 
33
2       DERIVED NULL    NULL    NULL    NULL    NULL    NULL    NULL    No tables used
 
34
create table t1 (a int not null);
 
35
create table t2 select * from t1 where 0=1 procedure analyse();
 
36
show create table t2;
 
37
Table   Create Table
 
38
t2      CREATE TABLE `t2` (
 
39
  `Field_name` varbinary(255) NOT NULL DEFAULT '',
 
40
  `Min_value` varbinary(255) DEFAULT NULL,
 
41
  `Max_value` varbinary(255) DEFAULT NULL,
 
42
  `Min_length` int(11) NOT NULL DEFAULT '0',
 
43
  `Max_length` int(11) NOT NULL DEFAULT '0',
 
44
  `Empties_or_zeros` int(11) NOT NULL DEFAULT '0',
 
45
  `Nulls` int(11) NOT NULL DEFAULT '0',
 
46
  `Avg_value_or_avg_length` varbinary(255) NOT NULL DEFAULT '',
 
47
  `Std` varbinary(255) DEFAULT NULL,
 
48
  `Optimal_fieldtype` varbinary(64) NOT NULL DEFAULT ''
 
49
) ENGINE=PBXT DEFAULT CHARSET=latin1
 
50
select * from t1 where 0=1 procedure analyse();
 
51
Field_name      Min_value       Max_value       Min_length      Max_length      Empties_or_zeros        Nulls   Avg_value_or_avg_length Std     Optimal_fieldtype
 
52
insert into t1 values(1);
 
53
drop table t2;
 
54
create table t2 select * from t1 where 0=1 procedure analyse();
 
55
show create table t2;
 
56
Table   Create Table
 
57
t2      CREATE TABLE `t2` (
 
58
  `Field_name` varbinary(255) NOT NULL DEFAULT '',
 
59
  `Min_value` varbinary(255) DEFAULT NULL,
 
60
  `Max_value` varbinary(255) DEFAULT NULL,
 
61
  `Min_length` int(11) NOT NULL DEFAULT '0',
 
62
  `Max_length` int(11) NOT NULL DEFAULT '0',
 
63
  `Empties_or_zeros` int(11) NOT NULL DEFAULT '0',
 
64
  `Nulls` int(11) NOT NULL DEFAULT '0',
 
65
  `Avg_value_or_avg_length` varbinary(255) NOT NULL DEFAULT '',
 
66
  `Std` varbinary(255) DEFAULT NULL,
 
67
  `Optimal_fieldtype` varbinary(64) NOT NULL DEFAULT ''
 
68
) ENGINE=PBXT DEFAULT CHARSET=latin1
 
69
select * from t2;
 
70
Field_name      Min_value       Max_value       Min_length      Max_length      Empties_or_zeros        Nulls   Avg_value_or_avg_length Std     Optimal_fieldtype
 
71
insert into t2 select * from t1 procedure analyse();
 
72
select * from t2;
 
73
Field_name      Min_value       Max_value       Min_length      Max_length      Empties_or_zeros        Nulls   Avg_value_or_avg_length Std     Optimal_fieldtype
 
74
test.t1.a       1       1       1       1       0       0       1.0000  0.0000  ENUM('1') NOT NULL
 
75
insert into t1 values(2);
 
76
drop table t2;
 
77
create table t2 select * from t1 where 0=1 procedure analyse();
 
78
show create table t2;
 
79
Table   Create Table
 
80
t2      CREATE TABLE `t2` (
 
81
  `Field_name` varbinary(255) NOT NULL DEFAULT '',
 
82
  `Min_value` varbinary(255) DEFAULT NULL,
 
83
  `Max_value` varbinary(255) DEFAULT NULL,
 
84
  `Min_length` int(11) NOT NULL DEFAULT '0',
 
85
  `Max_length` int(11) NOT NULL DEFAULT '0',
 
86
  `Empties_or_zeros` int(11) NOT NULL DEFAULT '0',
 
87
  `Nulls` int(11) NOT NULL DEFAULT '0',
 
88
  `Avg_value_or_avg_length` varbinary(255) NOT NULL DEFAULT '',
 
89
  `Std` varbinary(255) DEFAULT NULL,
 
90
  `Optimal_fieldtype` varbinary(64) NOT NULL DEFAULT ''
 
91
) ENGINE=PBXT DEFAULT CHARSET=latin1
 
92
select * from t2;
 
93
Field_name      Min_value       Max_value       Min_length      Max_length      Empties_or_zeros        Nulls   Avg_value_or_avg_length Std     Optimal_fieldtype
 
94
insert into t2 select * from t1 procedure analyse();
 
95
select * from t2;
 
96
Field_name      Min_value       Max_value       Min_length      Max_length      Empties_or_zeros        Nulls   Avg_value_or_avg_length Std     Optimal_fieldtype
 
97
test.t1.a       1       2       1       1       0       0       1.5000  0.5000  ENUM('1','2') NOT NULL
 
98
drop table t1,t2;
 
99
create table t1 (v varchar(128));
 
100
insert into t1 values ('abc'),('abc\'def\\hij\"klm\0opq'),('\''),('\"'),('\\'),('a\0'),('b\''),('c\"'),('d\\'),('\'b'),('\"c'),('\\d'),('a\0\0\0b'),('a\'\'\'\'b'),('a\"\"\"\"b'),('a\\\\\\\\b'),('\'\0\\\"'),('\'\''),('\"\"'),('\\\\'),('The\ZEnd');
 
101
select * from t1 procedure analyse();
 
102
Field_name      Min_value       Max_value       Min_length      Max_length      Empties_or_zeros        Nulls   Avg_value_or_avg_length Std     Optimal_fieldtype
 
103
test.t1.v       "       \\      1       19      0       0       3.7619  NULL    ENUM('"','""','"c','\'\0\\"','\'','\'\'','\'b','a\0\0\0b','a\0','a""""b','a\'\'\'\'b','abc','abc\'def\\hij"klm\0opq','a\\\\\\\\b','b\'','c"','d\\','The\ZEnd','\\','\\d','\\\\') NOT NULL
 
104
drop table t1;
 
105
create table t1 (df decimal(5,1));
 
106
insert into t1 values(1.1);
 
107
insert into t1 values(2.2);
 
108
select * from t1 procedure analyse();
 
109
Field_name      Min_value       Max_value       Min_length      Max_length      Empties_or_zeros        Nulls   Avg_value_or_avg_length Std     Optimal_fieldtype
 
110
test.t1.df      1.1     2.2     13      13      0       0       1.65000 0.55000 ENUM('1.1','2.2') NOT NULL
 
111
drop table t1;
 
112
create table t1 (d double);
 
113
insert into t1 values (100000);
 
114
select * from t1 procedure analyse (1,1);
 
115
Field_name      Min_value       Max_value       Min_length      Max_length      Empties_or_zeros        Nulls   Avg_value_or_avg_length Std     Optimal_fieldtype
 
116
test.t1.d       100000  100000  6       6       0       0       100000  0       MEDIUMINT(6) UNSIGNED NOT NULL
 
117
drop table t1;
 
118
create table t1 (product varchar(32), country_id int not null, year int,
 
119
profit int);
 
120
insert into t1  values ( 'Computer', 2,2000, 1200),
 
121
( 'TV', 1, 1999, 150),
 
122
( 'Calculator', 1, 1999,50),
 
123
( 'Computer', 1, 1999,1500),
 
124
( 'Computer', 1, 2000,1500),
 
125
( 'TV', 1, 2000, 150),
 
126
( 'TV', 2, 2000, 100),
 
127
( 'TV', 2, 2000, 100),
 
128
( 'Calculator', 1, 2000,75),
 
129
( 'Calculator', 2, 2000,75),
 
130
( 'TV', 1, 1999, 100),
 
131
( 'Computer', 1, 1999,1200),
 
132
( 'Computer', 2, 2000,1500),
 
133
( 'Calculator', 2, 2000,75),
 
134
( 'Phone', 3, 2003,10)
 
135
;
 
136
create table t2 (country_id int primary key, country char(20) not null);
 
137
insert into t2 values (1, 'USA'),(2,'India'), (3,'Finland');
 
138
select product, sum(profit),avg(profit) from t1 group by product with rollup procedure analyse();
 
139
Field_name      Min_value       Max_value       Min_length      Max_length      Empties_or_zeros        Nulls   Avg_value_or_avg_length Std     Optimal_fieldtype
 
140
test.t1.product Computer        TV      2       8       0       0       4.2500  NULL    ENUM('Computer','Phone','TV') NOT NULL
 
141
sum(profit)     10      6900    11      11      0       0       1946.2500       2867.6719       ENUM('10','275','600','6900') NOT NULL
 
142
avg(profit)     10.0000 1380.0000       16      16      0       0       394.68750000    570.20033144    ENUM('10.0000','68.7500','120.0000','1380.0000') NOT NULL
 
143
drop table t1,t2;