CUBRID Engine
latest
Main Page
Namespaces
Classes
Files
File List
File Members
statistics.h
Go to the documentation of this file.
1
/*
2
* Copyright 2008 Search Solution Corporation
3
* Copyright 2016 CUBRID Corporation
4
*
5
* Licensed under the Apache License, Version 2.0 (the "License");
6
* you may not use this file except in compliance with the License.
7
* You may obtain a copy of the License at
8
*
9
* http://www.apache.org/licenses/LICENSE-2.0
10
*
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
16
*
17
*/
18
19
20
/*
21
* STATISTICS.h -
22
*/
23
24
#ifndef _STATISTICS_H_
25
#define _STATISTICS_H_
26
27
#ident "$Id$"
28
29
#include <stdio.h>
30
#include "
dbtype_def.h
"
31
#include "
storage_common.h
"
32
#include "
object_domain.h
"
33
34
#define STATS_WITH_FULLSCAN true
35
#define STATS_WITH_SAMPLING false
36
37
#define STATS_SAMPLING_THRESHOLD 50
/* sampling trial count */
38
#define STATS_SAMPLING_LEAFS_MAX 8
/* sampling leaf pages */
39
40
/* disk-resident elements of pkeys[] field */
41
#define BTREE_STATS_PKEYS_NUM 8
42
#define BTREE_STATS_RESERVED_NUM 4
43
44
#define STATS_MIN_MAX_SIZE sizeof(DB_DATA)
45
46
/* free_and_init routine */
47
#define stats_free_statistics_and_init(stats) \
48
do \
49
{ \
50
stats_free_statistics ((stats)); \
51
(stats) = NULL; \
52
} \
53
while (0)
54
55
/* B+tree statistical information */
56
typedef
struct
btree_stats
BTREE_STATS
;
57
struct
btree_stats
58
{
59
BTID
btid
;
60
int
leafs
;
/* number of leaf pages including overflow pages */
61
int
pages
;
/* number of total pages */
62
int
height
;
/* the height of the B+tree */
63
int
keys
;
/* number of keys */
64
int
has_function
;
/* is a function index */
65
TP_DOMAIN
*
key_type
;
/* The key type for the B+tree */
66
int
pkeys_size
;
/* pkeys array size */
67
int
*
pkeys
;
/* partial keys info for example: index (a, b, ..., x) pkeys[0] -> # of {a} pkeys[1] ->
68
* # of {a, b} ... pkeys[pkeys_size-1] -> # of {a, b, ..., x} */
69
#if 0
/* reserved for future use */
70
int
reserved[
BTREE_STATS_RESERVED_NUM
];
71
#endif
72
};
73
74
/* Statistical Information about the attribute */
75
typedef
struct
attr_stats
ATTR_STATS
;
76
struct
attr_stats
77
{
78
int
id
;
79
DB_TYPE
type
;
80
int
n_btstats
;
/* number of B+tree statistics information */
81
BTREE_STATS
*
bt_stats
;
/* pointer to array of BTREE_STATS[n_btstats] */
82
};
83
84
/* Statistical Information about the class */
85
typedef
struct
class_stats
CLASS_STATS
;
86
struct
class_stats
87
{
88
unsigned
int
time_stamp
;
/* the time stamped when the stat info updated; used to get up-to-date stat info */
89
int
heap_num_objects
;
/* cardinality of the class; number of instances the class has */
90
int
heap_num_pages
;
/* number of pages the class occupy */
91
int
n_attrs
;
/* number of attributes; size of the attr_stats[] */
92
ATTR_STATS
*
attr_stats
;
/* pointer to the array of attribute statistics */
93
};
94
95
#if !defined(SERVER_MODE)
96
extern
int
stats_get_statistics
(
OID
* classoid,
unsigned
int
timestamp,
CLASS_STATS
** stats_p);
97
extern
void
stats_free_statistics
(
CLASS_STATS
* stats);
98
extern
void
stats_dump
(
const
char
*classname, FILE * fp);
99
#endif
/* !SERVER_MODE */
100
101
#endif
/* _STATISTICS_H_ */
btree_stats::keys
int keys
Definition:
statistics.h:63
BTREE_STATS_RESERVED_NUM
#define BTREE_STATS_RESERVED_NUM
Definition:
statistics.h:42
DB_TYPE
DB_TYPE
Definition:
dbtype_def.h:670
attr_stats
Definition:
statistics.h:76
attr_stats::n_btstats
int n_btstats
Definition:
statistics.h:80
btree_stats::pkeys_size
int pkeys_size
Definition:
statistics.h:66
btree_stats::key_type
TP_DOMAIN * key_type
Definition:
statistics.h:65
stats_dump
void stats_dump(const char *classname, FILE *fp)
Definition:
statistics_cl.c:294
storage_common.h
attr_stats::id
int id
Definition:
statistics.h:78
btree_stats::pkeys
int * pkeys
Definition:
statistics.h:67
stats_free_statistics
void stats_free_statistics(CLASS_STATS *stats)
Definition:
statistics_cl.c:253
btree_stats::btid
BTID btid
Definition:
statistics.h:59
stats_get_statistics
int stats_get_statistics(OID *classoid, unsigned int timestamp, CLASS_STATS **stats_p)
Definition:
statistics_cl.c:54
dbtype_def.h
class_stats
Definition:
statistics.h:86
tp_domain
Definition:
object_domain.h:72
btree_stats::pages
int pages
Definition:
statistics.h:61
class_stats::time_stamp
unsigned int time_stamp
Definition:
statistics.h:88
attr_stats::bt_stats
BTREE_STATS * bt_stats
Definition:
statistics.h:81
btree_stats::has_function
int has_function
Definition:
statistics.h:64
class_stats::heap_num_pages
int heap_num_pages
Definition:
statistics.h:90
class_stats::heap_num_objects
int heap_num_objects
Definition:
statistics.h:89
btree_stats::height
int height
Definition:
statistics.h:62
object_domain.h
db_identifier
Definition:
dbtype_def.h:960
btree_stats
Definition:
statistics.h:57
btid
Definition:
storage_common.h:199
class_stats::attr_stats
ATTR_STATS * attr_stats
Definition:
statistics.h:92
attr_stats::type
DB_TYPE type
Definition:
statistics.h:79
class_stats::n_attrs
int n_attrs
Definition:
statistics.h:91
btree_stats::leafs
int leafs
Definition:
statistics.h:60
src
storage
statistics.h
Generated by
1.8.11