A single table with 5 billion rows is slow and awkward. Every index is huge, a full scan reads everything, and routine work like deleting old data or rebuilding an index locks up the whole table. Partitioning solves this by cutting that one logical table into many physical pieces, each holding a subset of the rows. To your application it still looks like one table named orders, but underneath the database stores it as orders_2024_01, orders_2024_02, and so on.
The key idea is that you split rows along a column called the partition key. The database uses that key to decide which partition a row belongs to and, more importantly, which partitions a query needs to touch. A query for last week's orders only reads the recent partitions and skips the rest, an effect called partition pruning. That alone can turn a 30 second scan into a 200 millisecond one.
Partitioning is not the same as sharding, even though people use the words loosely. Partitioning keeps all the pieces inside one database instance on one machine. Sharding takes the same idea and puts each piece on a different server so you can scale write throughput and storage past what one machine can hold. Partitioning helps a single big database; sharding is how you escape a single big database.