WEBVTT

1
00:00:00.000 --> 00:00:02.380
Let us understand data partitioning.

2
00:00:02.700 --> 00:00:05.840
You organize school papers
into folders by month.

3
00:00:06.500 --> 00:00:09.760
Finding November work becomes
easier if you open only the

4
00:00:09.760 --> 00:00:13.620
November folder. Putting every
folder on the same desk does

5
00:00:13.620 --> 00:00:17.660
not create more desks. Likewise,
smaller table parts can

6
00:00:17.660 --> 00:00:20.800
improve maintenance or
pruning without adding another

7
00:00:20.800 --> 00:00:24.420
database machine. Partitioning
splits a dataset into

8
00:00:24.420 --> 00:00:28.460
manageable parts using rules
such as date ranges or key

9
00:00:28.460 --> 00:00:32.600
hashes. Table partitions can
remain inside one database;

10
00:00:33.380 --> 00:00:36.120
partitioning does not automatically
mean physical sharding

11
00:00:36.120 --> 00:00:39.420
across servers. Follow the normal path.

12
00:00:40.240 --> 00:00:43.740
History rows are grouped by
date. This organization can

13
00:00:43.740 --> 00:00:47.380
exist inside one database and
should not be confused with

14
00:00:47.380 --> 00:00:50.140
distributing ownership
across independent shards.

15
00:00:50.820 --> 00:00:53.940
Each month has a defined range
with explicit boundaries.

16
00:00:53.940 --> 00:00:58.020
Future data needs a matching
partition or a deliberately

17
00:00:58.020 --> 00:01:02.520
configured default behavior.
SeatSpot stores an increasing

18
00:01:02.520 --> 00:01:07.420
audit/history table. Date
partitions can make retention and

19
00:01:07.420 --> 00:01:10.380
time-bounded queries easier
while keeping current

20
00:01:10.380 --> 00:01:13.500
reservation transactions on
an appropriate authoritative

21
00:01:13.500 --> 00:01:18.780
path. Now change one condition.
A date-bounded query reaches

22
00:01:18.780 --> 00:01:22.880
the planner. The engine can
eliminate irrelevant ranges if

23
00:01:22.880 --> 00:01:26.600
its rules and the query expression
permit partition pruning.

24
00:01:27.320 --> 00:01:30.780
A common misunderstanding
is this: Table partitioning

25
00:01:30.780 --> 00:01:33.040
automatically scales across machines.

26
00:01:33.780 --> 00:01:36.960
Partitions can remain inside
the same database on the same

27
00:01:36.960 --> 00:01:40.900
machine. Think about this. A
monthly partitioned table is

28
00:01:40.900 --> 00:01:44.200
queried without a date
predicate. Must it read only one

29
00:01:44.200 --> 00:01:46.820
month? Pause the video
and make your prediction.

30
00:01:46.820 --> 00:01:51.400
No. Without a usable condition
the database may inspect many

31
00:01:51.400 --> 00:01:54.840
partitions. Check the query
plan instead of assuming

32
00:01:54.840 --> 00:01:58.560
pruning. Let us reason
with a concrete example.

33
00:01:59.080 --> 00:02:02.240
History contains one million
rows per month over two years.

34
00:02:02.900 --> 00:02:06.500
A query requests one month.
With useful pruning it may

35
00:02:06.500 --> 00:02:10.220
inspect a relevant partition
rather than all 24 million

36
00:02:10.220 --> 00:02:15.340
rows, but actual I/O depends
on predicates, indexes and

37
00:02:15.340 --> 00:02:18.360
plans. Use EXPLAIN in a test environment.

38
00:02:19.180 --> 00:02:22.720
Confirm pruning and retention
behavior instead of assuming a

39
00:02:22.720 --> 00:02:24.840
partitioned table is always faster.

40
00:02:25.520 --> 00:02:28.460
These figures are teaching
examples, not production

41
00:02:28.460 --> 00:02:32.220
guarantees. Turn the idea
into a design decision.

42
00:02:32.880 --> 00:02:36.080
The November partition
supplies the requested history.

43
00:02:36.620 --> 00:02:40.100
An appropriate index and query
plan can still be necessary

44
00:02:40.100 --> 00:02:43.760
inside that partition.
Retention can operate on old

45
00:02:43.760 --> 00:02:47.240
partitions, but removal
is a data-policy decision.

46
00:02:48.060 --> 00:02:51.280
Verify dependencies, recovery
requirements and correct

47
00:02:51.280 --> 00:02:53.340
boundaries before destructive maintenance.

48
00:02:54.020 --> 00:02:57.000
When you try the practice
task, look for this result.

49
00:02:57.720 --> 00:03:00.580
Partitioning can aid pruning
and lifecycle management

50
00:03:00.580 --> 00:03:03.000
without adding another database server.

51
00:03:04.000 --> 00:03:07.320
Check your understanding. A
query without the partition key

52
00:03:07.320 --> 00:03:10.880
may still inspect many
parts. More partitions do not

53
00:03:10.880 --> 00:03:14.520
automatically add machines,
guarantee speed or fix one

54
00:03:14.520 --> 00:03:18.800
hot-row lock. Here is a challenge.
A table is partitioned by

55
00:03:18.800 --> 00:03:21.880
date, but a query filters
only customer email.

56
00:03:22.460 --> 00:03:24.900
Must it be fast? Pause before the answer.

57
00:03:25.460 --> 00:03:28.880
No. The engine may inspect many
partitions without a useful

58
00:03:28.880 --> 00:03:32.220
date restriction. Examine
the actual plan and

59
00:03:32.220 --> 00:03:36.100
indexing/access pattern rather
than assuming partitioning

60
00:03:36.100 --> 00:03:39.860
alone helps. For an interview,
discuss partition keys,

61
00:03:40.180 --> 00:03:43.780
pruning, indexes and retention.
Say what you would measure,

62
00:03:44.160 --> 00:03:45.820
not only which tool you would buy.
