Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8587639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:37:01+00:00 2026-06-11T22:37:01+00:00

I can in my situation either partition by range or by list for my

  • 0

I can in my situation either partition by range or by list for my new website, below is an example of both which I can choose from,

partition BY LIST(`category`)( 
PARTITION p0 VALUES IN(0), 
PARTITION p1 VALUES IN(1), 
PARTITION p2 VALUES IN(2), 
PARTITION p3 VALUES IN(3),
PARTITION p4 VALUES IN(4),
PARTITION p5 VALUES IN(5),
PARTITION p6 VALUES IN(6)
);

Or I can do,

PARTITION BY RANGE (`category`)(
PARTITION p0 VALUES LESS THAN (1),
PARTITION p1 VALUES LESS THAN (2),
PARTITION p2 VALUES LESS THAN (3),
PARTITION p3 VALUES LESS THAN (4),
PARTITION p4 VALUES LESS THAN (5),
PARTITION p5 VALUES LESS THAN (6),
PARTITION p6 VALUES LESS THAN (7)
);

As I do not know anything about partitioning which one would be better to choose from?

Also I found out I can do something like this also,

partition BY HASH(`category`)
partitions 7;

Is there any better one to choose from or does it really not matter?

As a final question – I have 7 different categories. Choosing the last option what would happen if I was to use more than 7 partitions? Would this just be silly to do, or would it increase performance.

Thanks for taking the time to read my question!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T22:37:02+00:00Added an answer on June 11, 2026 at 10:37 pm

    You have 4 partitining strategies available in MySQL: RANGE, LIST, KEY AND HASH.

    If you need to partition by specific values of the partitioning column, RANGE and LIST are designed for this purppose. If you don’t need to assign rows to files by specific values of the column, then KEY and HASH are more suitable for you.

    In your case, all the three approaches (LIST, RANGE and HASH) work exactly the same way, as you have 7 partitions and rows with `category` = 0 will be stored in p0, `category` = 1 in p1 and so on.

    In a HASH partitioning, to determine which file will be used to store certain row, MySQL uses the modulo (mod) operation:

    partition_number = hash(partitioning_column) mod number_of_partitions

    In your HASH case, partition number would be:

    partition_number = category mod 7 (you are not using any hash function, so identity is used by default).

    Creating more (or less) partitions than values can have the partitining column is not necessarily useless but if you are using identity as hash function, then creating more partitions is useless.

    Imagine you have only 7 categories but you define 20 partitions:

    PARTITION BY HASH(`category`)
    PARTITIONS 20;
    

    As 0 mod 7 = 0, 1 mod 7 = 1, 2 mod 7 = 2, 3 mod 7 = 3, 4 mod 7 = 4, 5 mod 7 = 5 and 6 mod 7 = 6, the rest of partitions (p7-p19) will never be used. It doesn’t increases or decreases the performance, it’s just useless.

    Now imagine you still have your 7 categories, but you only have 4 partitions:

    PARTITION BY HASH(`category`)
    PARTITIONS 4;
    

    0 mod 4 = 0, 1 mod 4 = 1, 2 mod 4 = 2, 3 mod 4 = 3, 4 mod 4 = 0, 5 mod 4 = 1, 6 mod 4 = 2.

    What happened? that the file p0 will contain rows with `category` = 0 and `category` = 4, p1 will contain rows with `category` = 1 and `category` = 5, p2 will contain rows with `category` = 2 and `category` = 6 and p3 will contain only rows with `category` = 3.

    Would this increase or decrease the performance? it depends on the SELECT queries that you run on this table. If you run queries like this:

    SELECT * FROM `table_name` WHERE `category` = 0 or `category` = 4;
    

    it’s perfect as only one partition will be accessed. But this other example is the opposite:

    SELECT * 
    FROM `table_name` 
    WHERE `category` = 0 OR `category` = 1 OR `category` = 2 OR`category` = 3;
    

    all the partitions will need to be accessed to retrieve the data.

    MySQL gives you this info if you type:

    EXPLAIN PARTITIONS SELECT_QUERY;
    example: EXPLAIN PARTITIONS SELECT * FROM `table_name` WHERE `category` = 0 or `category` = 4;
    

    Regarding which alternative to use, as LIST and RANGE partitions are intended to specify a list or a range of values and you have only one value per partition, I would go for HASH partitioning in this case.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The Situation In Sharepoint 2010 I can click on an item in a list:
I have a situation whereby a thread can retrieve an object from the db,
Situation: I want to provide a website service where users can enter some data
Whenever there is dilemma to do a particular task, which can be accomplished either
A Person can either be a Pianist, which has a .play() method, either a
I am trying to make the situation like this: user can either fill in
I have a situation where I have 2 tables in which I can do
G'day, Edit: While this question covers a situation that can arise in programming a
how can I handle a situation, where a filed listens to a buttons that
I have situation where a user can manipulate a large set of data (presented

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.