简体   繁体   中英

Partition table in MySQL

We are designing a database for a multi tenant application that will be per tenant based. This tenant is potentially 1000 or more.

We have samples tables called:

orders

  1. tenantid
  2. orderid
  3. name
  4. date
  5. totalamount

orderitems

  1. tenantid
  2. orderitemid
  3. orderid
  4. productid
  5. quantity
  6. price

We are thinking to do partition based on tenantid so it can ran faster query within the tenant.

CREATE TABLE orders ( ... ) PARTITION BY HASH(tenantid) PARTITIONS ?;

Is that the best option to do this? How about the number of partition ... partition 1000?

I am appreciated your input.

Rules of thumb:

  • Don't use PARTITION on a table with less than a million rows.
  • Don't have more than about 50 partitions.
  • PARTITION BY HASH provides no performance benefit.

More discussion .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM