Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:01,390 --> 00:00:04,870
In this lesson, we're going to
study the concept of a database
2
00:00:04,870 --> 00:00:07,240
block in Oracle.
3
00:00:07,240 --> 00:00:11,080
So a database block is
the smallest atomic unit
4
00:00:11,080 --> 00:00:13,900
of space in an Oracle database.
5
00:00:13,900 --> 00:00:16,480
If you've ever heard the
concept of an operating system
6
00:00:16,480 --> 00:00:19,000
block or a file
system block, this
7
00:00:19,000 --> 00:00:21,130
is sort of analogous to that.
8
00:00:21,130 --> 00:00:25,240
So, when Oracle stores
space or reads space,
9
00:00:25,240 --> 00:00:29,680
it never reads less than
the size of an Oracle block.
10
00:00:29,680 --> 00:00:34,690
So, even if it only needs one
row that's maybe 100 bytes,
11
00:00:34,690 --> 00:00:38,170
it still reads the
entire block into memory.
12
00:00:38,170 --> 00:00:41,650
So database blocks
are stored on disk
13
00:00:41,650 --> 00:00:46,510
in the form of extents and
segments and then data files.
14
00:00:46,510 --> 00:00:49,240
But the blocks are the
smallest part of that.
15
00:00:49,240 --> 00:00:53,800
And so a database block is
read into a memory buffer
16
00:00:53,800 --> 00:00:56,320
or a buffer in the cache.
17
00:00:56,320 --> 00:00:58,720
So we have something
like the SGA
18
00:00:58,720 --> 00:01:01,390
and the buffer cache
that's present there.
19
00:01:01,390 --> 00:01:03,190
And so the database
blocks are actually
20
00:01:03,190 --> 00:01:05,780
read into those buffers.
21
00:01:05,780 --> 00:01:10,340
The database blocks size is
defined by the DB block size
22
00:01:10,340 --> 00:01:12,950
parameter in the database.
23
00:01:12,950 --> 00:01:15,560
And this is defined at creation.
24
00:01:15,560 --> 00:01:19,040
And, once the database is
created with a certain block
25
00:01:19,040 --> 00:01:21,320
size, it cannot be changed.
26
00:01:21,320 --> 00:01:23,840
So your only option if you
want to change the block
27
00:01:23,840 --> 00:01:28,190
size of the entire database
is to export all of the data
28
00:01:28,190 --> 00:01:32,180
out, recreate the database
with the new block size,
29
00:01:32,180 --> 00:01:34,730
and then import
the data back in.
30
00:01:34,730 --> 00:01:37,340
So the database
block sizes are going
31
00:01:37,340 --> 00:01:41,660
to match the buffer sizes
because a block fits perfectly
32
00:01:41,660 --> 00:01:43,650
into a buffer, if you will.
33
00:01:43,650 --> 00:01:46,970
So if we had an 8K block
size for the database,
34
00:01:46,970 --> 00:01:50,660
that means our buffers are
going to be 8K as well.
35
00:01:50,660 --> 00:01:54,020
And, since the block size cannot
be changed after creation,
36
00:01:54,020 --> 00:01:59,000
it's important that we know how
to properly size our database
37
00:01:59,000 --> 00:02:04,610
block, so what block size is
available to us and what is
38
00:02:04,610 --> 00:02:08,340
most advisable for
our certain situation.
39
00:02:08,340 --> 00:02:12,020
So, to look at the anatomy
of a database block a little,
40
00:02:12,020 --> 00:02:15,280
let's say this is
one database block.
41
00:02:15,280 --> 00:02:20,380
Database block consists of
header information, free space,
42
00:02:20,380 --> 00:02:22,060
and used space.
43
00:02:22,060 --> 00:02:24,040
So the header
information is going
44
00:02:24,040 --> 00:02:27,370
to be a small amount that's
used for the block that
45
00:02:27,370 --> 00:02:30,670
will have information,
such as something called
46
00:02:30,670 --> 00:02:33,880
the DBA or the
Data Block Address,
47
00:02:33,880 --> 00:02:37,150
where it's located
physically on disk,
48
00:02:37,150 --> 00:02:40,060
and some other information
about columns and tables
49
00:02:40,060 --> 00:02:42,720
that are within the block.
50
00:02:42,720 --> 00:02:45,540
The next section
is the free space.
51
00:02:45,540 --> 00:02:48,420
So a database block will
have space that's used
52
00:02:48,420 --> 00:02:50,030
and space that's not.
53
00:02:50,030 --> 00:02:52,080
And so the free
space will be what
54
00:02:52,080 --> 00:02:57,760
we constitute as the open and
available space for new rows.
55
00:02:57,760 --> 00:02:59,800
The used space
will be the actual
56
00:02:59,800 --> 00:03:03,490
rose on disk within the block.
57
00:03:03,490 --> 00:03:09,460
So, if we see here, we could
look at this as a row of data.
58
00:03:09,460 --> 00:03:13,240
And so the used space is going
to be filled with row data,
59
00:03:13,240 --> 00:03:15,910
and then the free space
will be available for use.
60
00:03:15,910 --> 00:03:21,010
So this line actually moves
within every database block.
61
00:03:21,010 --> 00:03:24,340
As a block begins to fill
up with more and more rows
62
00:03:24,340 --> 00:03:29,410
of data, this free space
gets less and less.
63
00:03:29,410 --> 00:03:32,230
So we said that this
sizing of a database block
64
00:03:32,230 --> 00:03:35,060
was very important because
it can't be changed.
65
00:03:35,060 --> 00:03:37,160
So what are our possibilities?
66
00:03:37,160 --> 00:03:41,200
Well, we can have a database
block size between 2 kilobytes
67
00:03:41,200 --> 00:03:43,150
and 32 kilobytes.
68
00:03:43,150 --> 00:03:46,480
So how do we decide
what is best?
69
00:03:46,480 --> 00:03:49,870
Well, let's start with
the middle which is 8K.
70
00:03:49,870 --> 00:03:55,390
So the sizing possibilities are
2K to 32k in a doubling order,
71
00:03:55,390 --> 00:03:56,200
if you will.
72
00:03:56,200 --> 00:03:58,930
2, 4, 8, 16, and 32.
73
00:03:58,930 --> 00:04:02,140
Those are the five possibilities
for our block size.
74
00:04:02,140 --> 00:04:04,840
The default is 8K.
75
00:04:04,840 --> 00:04:08,860
And, for most situations,
that's going to be a good size.
76
00:04:08,860 --> 00:04:11,000
Let's look at the top end.
77
00:04:11,000 --> 00:04:14,310
So the smallest block
possibility is 2K.
78
00:04:14,310 --> 00:04:17,290
2K will not be used
all that often.
79
00:04:17,290 --> 00:04:19,750
You won't generally see
it being used because it's
80
00:04:19,750 --> 00:04:22,030
a very small block size.
81
00:04:22,030 --> 00:04:25,180
The next is more
common and that is 4K.
82
00:04:25,180 --> 00:04:29,620
So a 4K block size is going
to be ideal for situations
83
00:04:29,620 --> 00:04:33,160
where the database does
something like, OLTP,
84
00:04:33,160 --> 00:04:36,290
a lot of online
transaction processing.
85
00:04:36,290 --> 00:04:40,210
So this is many small
discrete transactions.
86
00:04:40,210 --> 00:04:43,300
So we could think of an OLTP as
something like an order entry
87
00:04:43,300 --> 00:04:47,560
system, maybe an online
store of some kind
88
00:04:47,560 --> 00:04:51,370
because you go and
you have a page that
89
00:04:51,370 --> 00:04:54,550
shows you the possible
things that you can purchase,
90
00:04:54,550 --> 00:04:56,380
then you create a shopping cart.
91
00:04:56,380 --> 00:04:58,960
And, once you filled all that
information about your order,
92
00:04:58,960 --> 00:05:02,410
you click Submit and that's
a single discrete transaction
93
00:05:02,410 --> 00:05:04,360
that goes against the database.
94
00:05:04,360 --> 00:05:07,720
And so 4K works well for
this because we're not
95
00:05:07,720 --> 00:05:12,160
bringing more data into
cache than we really need.
96
00:05:12,160 --> 00:05:17,080
So small transactions lends to
a small database block size.
97
00:05:17,080 --> 00:05:20,720
Let's skip over 8 and go to 16K.
98
00:05:20,720 --> 00:05:25,370
16K is more appropriate for
things like data warehousing,
99
00:05:25,370 --> 00:05:29,740
dss, and where we're using
binary large objects.
100
00:05:29,740 --> 00:05:31,610
So why would that be?
101
00:05:31,610 --> 00:05:35,020
Well, a larger block
size of the 16K range
102
00:05:35,020 --> 00:05:37,600
is ideal for data warehousing
because of the way
103
00:05:37,600 --> 00:05:41,290
that we use a database
when it's a data warehouse.
104
00:05:41,290 --> 00:05:43,810
So a data warehouse
is going to really
105
00:05:43,810 --> 00:05:46,960
be very opposite of the OLTP.
106
00:05:46,960 --> 00:05:50,140
So, instead of a lot of
small discrete transactions,
107
00:05:50,140 --> 00:05:52,870
we tend to have a fewer
number of very, very
108
00:05:52,870 --> 00:05:54,850
large transactions.
109
00:05:54,850 --> 00:05:57,970
So data warehouse and
decision support systems
110
00:05:57,970 --> 00:06:01,180
are going to query
large amounts of data
111
00:06:01,180 --> 00:06:04,180
and then come up with some
kind of aggregate or report
112
00:06:04,180 --> 00:06:05,320
from that.
113
00:06:05,320 --> 00:06:09,120
And, because of that, because
we're selecting that much data,
114
00:06:09,120 --> 00:06:12,340
a 16K is a good block
size because we'll
115
00:06:12,340 --> 00:06:15,340
tend to use fewer blocks.
116
00:06:15,340 --> 00:06:19,480
So, if we were using a 4K
block size in a data warehouse,
117
00:06:19,480 --> 00:06:22,000
that's four times
more blocks that we
118
00:06:22,000 --> 00:06:23,590
have to bring into cache.
119
00:06:23,590 --> 00:06:26,950
So it's more effective
generally to use 16K
120
00:06:26,950 --> 00:06:28,330
for data warehousing.
121
00:06:28,330 --> 00:06:31,270
And the other type is
binary large objects.
122
00:06:31,270 --> 00:06:34,060
So that will occur if
we're storing things
123
00:06:34,060 --> 00:06:36,940
like binary data
in the database.
124
00:06:36,940 --> 00:06:42,310
So if we're storing video files,
image files in some cases.
125
00:06:42,310 --> 00:06:43,660
Documents.
126
00:06:43,660 --> 00:06:47,380
Document management systems
are all the rage these days.
127
00:06:47,380 --> 00:06:49,840
And, rather than store
all of those documents
128
00:06:49,840 --> 00:06:52,240
out in a file system,
Oracle allows you
129
00:06:52,240 --> 00:06:53,920
to store it in the database.
130
00:06:53,920 --> 00:06:56,530
So you might have
PDFs or Word documents
131
00:06:56,530 --> 00:07:00,040
that are actually stored in the
database as a pod of a database
132
00:07:00,040 --> 00:07:00,850
row.
133
00:07:00,850 --> 00:07:04,840
But, because they're larger
than a typical var car 2
134
00:07:04,840 --> 00:07:08,500
string, or a date,
or a number, it's
135
00:07:08,500 --> 00:07:10,870
often advantageous
to use a larger block
136
00:07:10,870 --> 00:07:14,110
size along the 16K range.
137
00:07:14,110 --> 00:07:15,700
32K is the largest.
138
00:07:15,700 --> 00:07:18,010
And, again, that's the
other end of the spectrum
139
00:07:18,010 --> 00:07:19,870
and you don't see that as often.
140
00:07:19,870 --> 00:07:21,820
But, where you do,
it will tend to be
141
00:07:21,820 --> 00:07:25,720
things like data warehousing
and decision support systems.
142
00:07:25,720 --> 00:07:27,730
So that leaves us with 8K.
143
00:07:27,730 --> 00:07:31,510
To go back to it again, 8K
is the default block size,
144
00:07:31,510 --> 00:07:35,240
and we said that that is
generally a pretty good choice.
145
00:07:35,240 --> 00:07:38,480
It splits the middle as far
as what's available to us.
146
00:07:38,480 --> 00:07:40,810
And it's very good
for hybrid systems.
147
00:07:40,810 --> 00:07:44,710
So, these days, hybrid
systems are very common.
148
00:07:44,710 --> 00:07:46,240
And so what's a hybrid system?
149
00:07:46,240 --> 00:07:50,980
Well, a hybrid system may have
some characteristics of an OLTP
150
00:07:50,980 --> 00:07:55,750
and some characteristics of
a data warehousing or ETL
151
00:07:55,750 --> 00:08:00,670
kind of load heavy database
where lots of data is loaded.
152
00:08:00,670 --> 00:08:03,100
So, a lot of times,
during business hours,
153
00:08:03,100 --> 00:08:06,730
the database may function as
a transactional processing
154
00:08:06,730 --> 00:08:07,630
system.
155
00:08:07,630 --> 00:08:10,090
And at night data
will be loaded.
156
00:08:10,090 --> 00:08:13,240
And so it's good to have
a block size that kind of
157
00:08:13,240 --> 00:08:16,570
splits those two and makes
the best of both worlds
158
00:08:16,570 --> 00:08:18,520
available to us.
12900
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.