Do unused columns in MySQL/MariaDB notably affect performance?

All we need is an easy explanation of the problem, so here it is.

In the WordPress MySQL/MariaDB database there is a table with some columns that in my own uses of WordPress are never used.

The exact columns I am talking about are:

comment_status varchar(20)
ping_status varchar(20)
to_ping text
pinged text
comment_count bigint(20)

None of them is part of an index.

I wonder if removing those columns would make a notable performance difference.

Of course I cannot just remove those columns without modifying the WordPress core. My real goal behind the question is to gain feedback to know if it’s worth the effort to participate in the WordPress development and find an alternative way to manage that information for websites still using those columns.

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

Unused columns do carry a cost, but rarely one that most people will notice or care about in systems with well-written, targeted queries. If you are curious about testing performance and contributing in a meaningful way to the WordPress project, you might want to consider doing something like this:

  1. Make a workable backup of your WordPress database. For example:

    sudo mysqldump wordpress > wordpress.sql
    

    Note: This assumes you would create backups via a command-line. If you prefer GUIs, make a backup in your preferred way.

  2. Drop the columns that you think you can live without:

    ALTER TABLE wp_posts DROP COLUMN comment_status;
    ALTER TABLE wp_posts DROP COLUMN ping_status;
    ALTER TABLE wp_posts DROP COLUMN to_ping;
    ALTER TABLE wp_posts DROP COLUMN pinged;
    ALTER TABLE wp_posts DROP COLUMN comment_count;
    
  3. See what breaks over the next few days. If WordPress is unhappy about something, it is not shy about telling the world that something is wrong.

    Then, if nothing bad happens…

  4. Begin modifying the WordPress API to handle those fields differently (if at all) and tweak the database to be more performant.

Working on a large project like WordPress can bring a great deal of satisfaction, particularly if any of your modifications are adopted by the core project.

Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply