‫All right, so what is partitioning, guys, so let's say we have a beautiful customer stable here,
‫this is like, I don't know, one million roll of ten million is not that bad guys, by the way.
‫But if I want to pick the name of a customer with this particular 701.
‫Right.
‫So you going to select name from customer tables where ID equals seven hundred thousand and one.
‫So what the database will do is, well, if you have an index on the on that table, we're going to
‫use their index and then we're going to land on that particular roll on that disk.
‫Right.
‫Or if we don't have it, we're going to do a sequential scan, which is that does the worst thing we
‫can do.
‫But we have to scan all this rolls until we find the rolls we were looking for, regardless whether
‫using an index or sequential scan, scanning 100 million row is a lot.
‫Right.
‫And multiply that by ten or thousand billion rolls.
‫That's going to slow things down.
‫Index large tables are always slow to query regardless.
‫Right.
‫So what do we do?
‫Partitioning is the idea here is break the table down to smaller pieces so we know we only work with
‫so many rolls and instead of a larger set of rules.
‫So that's the one idea.
‫Let's break up this.
‫One million rolls into five partitions, five tables, partition, nothing but a table.
‫And we're going to name them customers to 100K customers, 400 customers, 600 customers, 800 customers,
‫a one one million.
‫So that means basically these are the customers between one and two hundred.
‫These are the customers going to 201 and 400 customers, between 400 and one and 600 and so on.
‫You get the idea.
‫Right.
‫So that's just how we partitioned it.
‫And then the database magically, you're going to attach these partition to the to the to the main table,
‫which is customer stable.
‫So customers tables, just almost like a parent or inheritance doesn't have any data that actual data
‫exists on these tables.
‫So now what I do is I'm going to do the same exact way, select name from customers table where I'd
‫go seven hundred and one.
‫And the first question is, I'm going to send that query.
‫What do we do?
‫Where does this idea exist?
‫And that's a very quick check by the database was like seven hundred and one.
‫Which table should I query this, this, this, this or this.
‫It's very easy because what's partition is customer has 700, 800.
‫On one end, we have the definitions in this partition that is metadata attached it where 079 is between
‫800 and 1000000, which is which is I mean 600 and 800.
‫So that's exactly the table we need to query.
‫So partition customers 800, we hit that table immediately.
‫So now I'm working only with two hundred thousand rows, which is beautiful.
‫I always say I tweet that the other day that the quickest way to query a table with a billion rows is
‫to avoid querying a table with a billion euros.
‫And that's what the data is.
‫Do they just try to as much as possible to avoid querying this much data and work with smaller set of
‫data?
‫That's the trick here.
‫All right.
‫So now once I have this, if I have an index even better, right, I'm going to use the index and then
‫land on customer 710000 and one which is calm in this case.