Comments on: The Ultimate Guide to MySQL Partitions https://www.percona.com/blog/what-is-mysql-partitioning/ Tue, 22 Aug 2023 14:05:37 +0000 hourly 1 https://wordpress.org/?v=6.5.2 By: Ram https://www.percona.com/blog/what-is-mysql-partitioning/#comment-10968757 Wed, 06 Dec 2017 11:16:08 +0000 https://www.percona.com/blog/?p=44386#comment-10968757 Thank you guys for the interesting discussion..

We are working on a project which if successful may have Billion of rows in a single table. Currently, we are working on to build a MVP and will do proof of value.

We are bit worried on the number of potential rows a single table may have. We were looking for guidance on partitioning vs index and/or both. We will have an variable (say customer ID in product table) which can be used for creating almost separate tables for each customer.

Would you suggest that we create a reference table which direct to a product table (which gets created) for a customer? Or we do partitioning only..

]]>
By: Rick James https://www.percona.com/blog/what-is-mysql-partitioning/#comment-10968546 Wed, 11 Oct 2017 17:58:02 +0000 https://www.percona.com/blog/?p=44386#comment-10968546 In reply to Abe.

Indexes are also designed for cutting down on how much you need to read.

]]>
By: Manjot Singh https://www.percona.com/blog/what-is-mysql-partitioning/#comment-10968545 Wed, 11 Oct 2017 17:02:53 +0000 https://www.percona.com/blog/?p=44386#comment-10968545 In reply to Abe.

exactly!

]]>
By: Manjot Singh https://www.percona.com/blog/what-is-mysql-partitioning/#comment-10968544 Wed, 11 Oct 2017 17:02:33 +0000 https://www.percona.com/blog/?p=44386#comment-10968544 In reply to Rick James.

It all depends on your workload. I recommend partitioning in a lot of cases. There are many people out there with 2B row tables and only access the last 5% of it 99% of the time.

]]>
By: Abe https://www.percona.com/blog/what-is-mysql-partitioning/#comment-10968543 Wed, 11 Oct 2017 16:08:56 +0000 https://www.percona.com/blog/?p=44386#comment-10968543 if I´m right, partitioning means that the table will be split in many files, giving the advantage to just read in one file with the small size instead of read in one big file, off course the queries should be designed for that.

]]>
By: Rick James https://www.percona.com/blog/what-is-mysql-partitioning/#comment-10968484 Fri, 22 Sep 2017 04:04:27 +0000 https://www.percona.com/blog/?p=44386#comment-10968484 Can you provide a 5th use case where Partitioning improves performance? See http://mysql.rjweb.org/doc.php/partitionmaint for the 4 cases I know of.

(I can’t imagine how your example of Hash “load balancing” provides any performance benefit. Do you have ‘proof’?)

]]>
By: Rick James https://www.percona.com/blog/what-is-mysql-partitioning/#comment-10968483 Fri, 22 Sep 2017 04:01:54 +0000 https://www.percona.com/blog/?p=44386#comment-10968483 In reply to Mayank Tyagi.

Mayank, the solution is simple: Also have INDEX(id). The only thing that AUTO_INCREMENT requires is that the id be first in some index. It does not require PK or UNIQUE. (However, without a uniqueness constraint it is possible to insert a duplicate id — but who would do that!)

I have used this technique several times. It provides the performance benefit of “clustering” on part_id, while still having a UNIQUE primary key. That is, it is beneficial for a SELECT … WHERE part_id = 123 with multiple rows of 123. And for SELECT … WHERE part_id BETWEEN … .

Note that PARTITIONing add no benefit to either of those SELECTs.

]]>
By: Rick James https://www.percona.com/blog/what-is-mysql-partitioning/#comment-10968482 Fri, 22 Sep 2017 03:56:06 +0000 https://www.percona.com/blog/?p=44386#comment-10968482 And, yet, you would be surprised at how few use cases get any performance benefit with PARTITIONing versus a better index on a non-partitioned table.

]]>
By: Mayank Tyagi https://www.percona.com/blog/what-is-mysql-partitioning/#comment-10968323 Fri, 28 Jul 2017 05:58:51 +0000 https://www.percona.com/blog/?p=44386#comment-10968323 Hi Manjot, I think PRIMARY KEY (part_id,id), where id is auto increment column, wont work. Because the auto increment column should be in first position while creating the composite primary key.

]]>