All language subtitles for [SubtitleTools.com] Partitions - Learning Oracle 12c [Video]

af Afrikaans
sq Albanian
am Amharic
ar Arabic Download
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bn Bengali
bs Bosnian
bg Bulgarian
ca Catalan
ceb Cebuano
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
tl Filipino
fi Finnish
fr French
fy Frisian
gl Galician
ka Georgian
de German
el Greek
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
km Khmer
ko Korean
ku Kurdish (Kurmanji)
ky Kyrgyz
lo Lao
la Latin
lv Latvian
lt Lithuanian
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mn Mongolian
my Myanmar (Burmese)
ne Nepali
no Norwegian
ps Pashto
fa Persian
pl Polish
pt Portuguese
pa Punjabi
ro Romanian
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
st Sesotho
sn Shona
sd Sindhi
si Sinhala
sk Slovak
sl Slovenian
so Somali
es Spanish
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
te Telugu
th Thai
tr Turkish
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
or Odia (Oriya)
rw Kinyarwanda
tk Turkmen
tt Tatar
ug Uyghur
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:01,290 --> 00:00:02,660 In this lesson, we're going to be 2 00:00:02,660 --> 00:00:06,590 looking at partitioning, or partitioned tables. 3 00:00:06,590 --> 00:00:10,340 So partitioning is the act of breaking a large table 4 00:00:10,340 --> 00:00:12,350 into more manageable pieces. 5 00:00:12,350 --> 00:00:14,840 And so we are talking about very large tables 6 00:00:14,840 --> 00:00:16,460 here, for the most part. 7 00:00:16,460 --> 00:00:19,310 The most important thing to remember about a partition 8 00:00:19,310 --> 00:00:24,620 table is that it must be partitioned on a partition key. 9 00:00:24,620 --> 00:00:28,570 So a key value is what we would partition on. 10 00:00:28,570 --> 00:00:32,240 And when we say that we're partitioning on a key value, 11 00:00:32,240 --> 00:00:36,140 that means we're breaking the table into separations 12 00:00:36,140 --> 00:00:39,180 based on that key value. 13 00:00:39,180 --> 00:00:42,510 Partitioning is not preferable in every situation. 14 00:00:42,510 --> 00:00:46,380 So if we have, let's say, an order entry table, 15 00:00:46,380 --> 00:00:52,020 and it has 3 million rows, if we decide to partition the order 16 00:00:52,020 --> 00:00:56,460 entry table based on the order ID key, 17 00:00:56,460 --> 00:00:59,340 then we're saying we're going to split the table based 18 00:00:59,340 --> 00:01:00,600 on that key. 19 00:01:00,600 --> 00:01:04,350 However, if we don't query against the table based 20 00:01:04,350 --> 00:01:07,020 on that key value, then the partitioning 21 00:01:07,020 --> 00:01:08,910 is actually going to be more of a hindrance, 22 00:01:08,910 --> 00:01:12,240 because of the overhead involved, than a help. 23 00:01:12,240 --> 00:01:15,450 However, when we have large tables, 24 00:01:15,450 --> 00:01:18,660 partitioning can be of huge performance benefit 25 00:01:18,660 --> 00:01:23,200 because we're excluding so many other parts of the data. 26 00:01:23,200 --> 00:01:26,620 So let's take a look at how this functions. 27 00:01:26,620 --> 00:01:29,210 So here is our 3 million row table. 28 00:01:29,210 --> 00:01:32,010 Now, 3 million rows might be a little on the small side 29 00:01:32,010 --> 00:01:33,670 for a partition table. 30 00:01:33,670 --> 00:01:36,990 Normally, we're talking about dozens of millions or hundreds 31 00:01:36,990 --> 00:01:38,350 of millions of rows. 32 00:01:38,350 --> 00:01:41,160 But it makes a good example here for a visual. 33 00:01:41,160 --> 00:01:43,440 So we have the Order Entry table. 34 00:01:43,440 --> 00:01:47,190 And we're partitioning based on the Order ID column. 35 00:01:47,190 --> 00:01:51,420 So what that means is that the rows of the table that 36 00:01:51,420 --> 00:01:55,170 have an order ID of 0 to 1 million 37 00:01:55,170 --> 00:01:59,460 will be in this partition, those with 1 million to 2 million 38 00:01:59,460 --> 00:02:02,880 in this partition, and 2 to 3 in this one. 39 00:02:02,880 --> 00:02:05,080 So we're dividing the table. 40 00:02:05,080 --> 00:02:06,910 So how does this help us? 41 00:02:06,910 --> 00:02:10,200 Well, let's say we were searching for a particular row 42 00:02:10,200 --> 00:02:12,660 in this 3 million row table. 43 00:02:12,660 --> 00:02:16,830 So we want to do a select star from order entry 44 00:02:16,830 --> 00:02:21,180 where order ID equals 1,000,001 as a value. 45 00:02:21,180 --> 00:02:24,450 So ordinarily, if we had a 3 million row table, 46 00:02:24,450 --> 00:02:26,370 and it was not partitioned, Oracle 47 00:02:26,370 --> 00:02:29,550 would have to either do a full table scan of all 48 00:02:29,550 --> 00:02:34,770 3 million rows or at least an index scan of 3 million values 49 00:02:34,770 --> 00:02:37,960 in order to find that particular row. 50 00:02:37,960 --> 00:02:40,050 But if a table is partition, it's 51 00:02:40,050 --> 00:02:42,970 been broken up into these different pieces. 52 00:02:42,970 --> 00:02:46,260 So now, if we do a select star from order entry 53 00:02:46,260 --> 00:02:50,700 where order ID equals 1,000,001, our partitioning scheme 54 00:02:50,700 --> 00:02:53,760 allows us to go directly to this partition. 55 00:02:53,760 --> 00:02:58,080 And what we've done is exclude 2/3 of the data in the table 56 00:02:58,080 --> 00:03:00,930 immediately as a part of the execution plan. 57 00:03:00,930 --> 00:03:03,060 So those are excluded and we don't even 58 00:03:03,060 --> 00:03:04,670 have to query against them. 59 00:03:04,670 --> 00:03:05,790 We don't have to scan them. 60 00:03:05,790 --> 00:03:08,190 We don't have to scan their index values. 61 00:03:08,190 --> 00:03:11,250 And now, instead of scanning either 3 million rows 62 00:03:11,250 --> 00:03:14,820 or 3 million index values, we're limited to only 1 million, 63 00:03:14,820 --> 00:03:16,710 which is much more manageable. 64 00:03:16,710 --> 00:03:19,080 Another benefit of partitioning is that we could actually 65 00:03:19,080 --> 00:03:23,100 separate these partitions out into different disks, 66 00:03:23,100 --> 00:03:26,940 separate them out to a D drive, an E drive, and an F drive, 67 00:03:26,940 --> 00:03:28,020 for instance. 68 00:03:28,020 --> 00:03:31,110 And that often will help with the performance 69 00:03:31,110 --> 00:03:35,830 of the I/O that has to be done against the table as well. 70 00:03:35,830 --> 00:03:37,660 So there are different types of partitioning 71 00:03:37,660 --> 00:03:39,460 that we can do in Oracle. 72 00:03:39,460 --> 00:03:43,130 Oracle continues to add new ways to partition data. 73 00:03:43,130 --> 00:03:46,030 The first is range partitioning. 74 00:03:46,030 --> 00:03:49,690 And so in range partitioning our partition scheme 75 00:03:49,690 --> 00:03:52,690 is based on a range of values, just as the order entry 76 00:03:52,690 --> 00:03:54,620 table we just looked at. 77 00:03:54,620 --> 00:03:57,100 So the range of values of 0 to 1 million 78 00:03:57,100 --> 00:03:59,560 and 1 million to 2 million and so forth, 79 00:03:59,560 --> 00:04:02,770 a range of values on the partition key. 80 00:04:02,770 --> 00:04:04,780 Another type is hash partitioning. 81 00:04:04,780 --> 00:04:07,150 Hash partitioning is an interesting type, 82 00:04:07,150 --> 00:04:10,480 because in hash partitioning we simply direct, 83 00:04:10,480 --> 00:04:13,030 when we create the table, and say, 84 00:04:13,030 --> 00:04:15,370 I want to have 10 partitions. 85 00:04:15,370 --> 00:04:19,360 We don't give it any other specifications than that. 86 00:04:19,360 --> 00:04:22,450 And so then Oracle uses a hashing algorithm 87 00:04:22,450 --> 00:04:26,710 to decide how to populate those 10 different partitions. 88 00:04:26,710 --> 00:04:29,170 And it normally does a pretty good job of that, 89 00:04:29,170 --> 00:04:31,960 but it won't be as, you know, right on the money 90 00:04:31,960 --> 00:04:35,510 accurate as range partition table would be. 91 00:04:35,510 --> 00:04:38,740 But hash partitioning is much easier to manage. 92 00:04:38,740 --> 00:04:41,860 List partitioning is partitioning based 93 00:04:41,860 --> 00:04:44,600 on a fixed list of values. 94 00:04:44,600 --> 00:04:47,920 So if we have a column that has a certain fixed 95 00:04:47,920 --> 00:04:52,120 number of values in it, we may want to partition on that key. 96 00:04:52,120 --> 00:04:55,960 So something like our company's location, 97 00:04:55,960 --> 00:04:59,380 so company offices located in the North or the South 98 00:04:59,380 --> 00:05:02,050 or the Northwest or the Southeast, 99 00:05:02,050 --> 00:05:04,290 and has those fixed values. 100 00:05:04,290 --> 00:05:07,270 And we can partition and put all of the values for North 101 00:05:07,270 --> 00:05:10,870 in a partition, all the values for Northeast in a partition, 102 00:05:10,870 --> 00:05:12,890 and so on and so forth. 103 00:05:12,890 --> 00:05:17,250 Composite partitioning would be for even larger tables usually. 104 00:05:17,250 --> 00:05:19,160 And in composite partitioning, we 105 00:05:19,160 --> 00:05:23,210 use combinations of these types of partitioning 106 00:05:23,210 --> 00:05:25,490 and into sub-partitions. 107 00:05:25,490 --> 00:05:28,010 So we have a layer of partitions. 108 00:05:28,010 --> 00:05:30,290 And then those partitions are broken further down 109 00:05:30,290 --> 00:05:32,100 into sub-partitions. 110 00:05:32,100 --> 00:05:37,100 And so we may partition based on range and then sub-partition 111 00:05:37,100 --> 00:05:38,990 based on hash. 112 00:05:38,990 --> 00:05:42,110 So let's take a look at a couple of examples 113 00:05:42,110 --> 00:05:44,210 of partition tables. 114 00:05:44,210 --> 00:05:47,360 First and foremost, we notice that the first section 115 00:05:47,360 --> 00:05:51,030 is completely ordinary from a table perspective. 116 00:05:51,030 --> 00:05:53,810 So if we wanted this to be a non-partitioned table, 117 00:05:53,810 --> 00:05:56,690 we could simply run this section and it 118 00:05:56,690 --> 00:05:58,100 would be completely legitimate. 119 00:05:58,100 --> 00:06:02,010 And it would create the order entry range table. 120 00:06:02,010 --> 00:06:06,440 So we have columns, data types, just like a normal table. 121 00:06:06,440 --> 00:06:10,280 What makes it a partition table is the following section, 122 00:06:10,280 --> 00:06:12,290 follows the definition of the table. 123 00:06:12,290 --> 00:06:15,260 And we say partition by range. 124 00:06:15,260 --> 00:06:18,230 Then we give it a partition key. 125 00:06:18,230 --> 00:06:21,530 So we're specifying that the order ID column-- 126 00:06:21,530 --> 00:06:26,570 that's this here-- will be used as the partition key. 127 00:06:26,570 --> 00:06:28,730 And then we define the partitions out. 128 00:06:28,730 --> 00:06:30,490 Say the keyword partition. 129 00:06:30,490 --> 00:06:35,840 We give the partition a name, values less than 1 million 130 00:06:35,840 --> 00:06:39,770 and then values less than 2 million for the next partition 131 00:06:39,770 --> 00:06:41,630 and values less than 3 million. 132 00:06:41,630 --> 00:06:43,520 And so what's implied here when we 133 00:06:43,520 --> 00:06:45,950 do range partitioning in this way 134 00:06:45,950 --> 00:06:51,980 is values from 0 to 1 million essentially will be in par 0. 135 00:06:51,980 --> 00:06:55,940 Values less than 2 million but greater than 1 million 136 00:06:55,940 --> 00:06:59,320 will be in par 1, and so forth. 137 00:06:59,320 --> 00:07:02,000 So let's create our partitioned table, 138 00:07:02,000 --> 00:07:03,490 our range partitioned table. 139 00:07:06,660 --> 00:07:10,240 Next, let's look at a hash partitioned table. 140 00:07:10,240 --> 00:07:13,860 So here, we're creating the table order entry hash just 141 00:07:13,860 --> 00:07:15,960 to specify it is hash partitioned. 142 00:07:15,960 --> 00:07:17,970 Again, same columns. 143 00:07:17,970 --> 00:07:21,300 All of the first section in the statement 144 00:07:21,300 --> 00:07:25,470 is exactly like a normal table, a heap organized table. 145 00:07:25,470 --> 00:07:30,840 But in a hash partitioned table, we say partition by hash. 146 00:07:30,840 --> 00:07:33,780 And as always, we give it a partition key. 147 00:07:33,780 --> 00:07:35,370 And we say the number of partitions. 148 00:07:35,370 --> 00:07:37,770 So in this case partition is 3. 149 00:07:37,770 --> 00:07:40,200 So here, we're saying we want to create this table. 150 00:07:40,200 --> 00:07:42,900 We want it partitioned in three partition. 151 00:07:42,900 --> 00:07:44,850 But we're using hash partitions. 152 00:07:44,850 --> 00:07:47,640 So Oracle uses the hashing algorithm 153 00:07:47,640 --> 00:07:51,300 to decide which values go in which partition. 154 00:07:51,300 --> 00:07:53,070 So essentially here, we're saying 155 00:07:53,070 --> 00:07:55,680 we want the benefits of a partition table. 156 00:07:55,680 --> 00:07:58,020 We want the separation of data. 157 00:07:58,020 --> 00:08:01,680 But we don't want to micromanage exactly every part of data that 158 00:08:01,680 --> 00:08:05,670 goes to a particular partition. 159 00:08:05,670 --> 00:08:08,470 Lastly is the list partition table. 160 00:08:08,470 --> 00:08:13,800 So again, first section exactly like a normal table. 161 00:08:13,800 --> 00:08:16,950 And we say partition by list. 162 00:08:16,950 --> 00:08:21,330 And this time we're going to use the Order Region column, and so 163 00:08:21,330 --> 00:08:23,940 the region that the order comes from. 164 00:08:23,940 --> 00:08:29,040 And we say partition, partition name, so par n, and then 165 00:08:29,040 --> 00:08:32,070 the values South and Southwest. 166 00:08:32,070 --> 00:08:35,380 Par s is values North and Northeast. 167 00:08:35,380 --> 00:08:38,370 And par m is values Midwest. 168 00:08:38,370 --> 00:08:43,530 So anytime a row is put into the order entry list table 169 00:08:43,530 --> 00:08:45,510 and the order region column value 170 00:08:45,510 --> 00:08:50,140 is either South or Southwest, it goes in this partition. 171 00:08:50,140 --> 00:08:53,250 And if it's in North or Northeast, 172 00:08:53,250 --> 00:08:57,260 it goes in this partition, so on and so forth. 173 00:08:57,260 --> 00:09:00,630 We'll go ahead and run that as well. 174 00:09:00,630 --> 00:09:03,380 So that's order entry list. 175 00:09:03,380 --> 00:09:06,890 Actually, I forgot to come up here and run our hash partition 176 00:09:06,890 --> 00:09:08,520 table. 177 00:09:08,520 --> 00:09:10,140 So what we can see here is we can 178 00:09:10,140 --> 00:09:12,390 get the benefit of partitioning just 179 00:09:12,390 --> 00:09:15,570 by doing a little more code in the initial creation 180 00:09:15,570 --> 00:09:16,500 of the table. 181 00:09:16,500 --> 00:09:18,510 And then we can get that performance benefit 182 00:09:18,510 --> 00:09:20,470 for large tables. 14888

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.