0

I am trying to learn mySQL database, and have started taking a look at the database behind wordpress. I am using the Wordpress Data Base Descrition to review the structure and I came upon the following:

|Table: wp_commentmeta|
---------------------------------------------------------------------------------
|Field      |Type                |Null  |Key |Default | Extra  
|-----------|--------------------|------|----|--------|--------------------------
|meta_id    |bigint(20) unsigned |      |PRI |NULL    |auto_increment  
|comment_id |bigint(20) unsigned |      |IND |0       |FK->wp_comments.comment_id  
|meta_key   |varchar(255)        |YES   |IND |NULL    |
|meta_value |longtext            |YES   |    |NULL    |



|Indexes|
---------------------------------------------------------
|Keyname     |Type     |Cardinality |Field  
|------------|---------|------------|--------------------
|PRIMARY     |PRIMARY  |0           |meta_ID  
|comment_id  |INDEX    |none        |comment_id  
|meta_key    |INDEX    |none        |meta_key  

My question is, what does a Cardinality value of 0 indicate in the table above. I understand the explanation of cardinality as explained in this SO answer in that it is the number of unique values within a particular set of indexed values, but I dont get what setting a value of 0 does in this particular case.

Community
  • 1
  • 1
Hari Seldon
  • 1,060
  • 2
  • 13
  • 27

2 Answers2

1

Is your table empty? I think this just says that you have 0 rows in your table. In other words, it's not a "setting", it's just a count of how many nodes you have in your index.

Simon Ouellette
  • 111
  • 1
  • 1
  • 6
  • The table isnt from a specific instance of the wordpress database, but desribes the schema of the database. There is another table described on that same page with a Cardinality value of 1. – Hari Seldon Oct 29 '11 at 18:00
  • Well, I guess it could be describing the initial state of the table, as in not having any rows in it... There is an options table with a cardinality of 184, which would make sense to have many options available but zero comments in a new instance of the database.... thanks for the response @Simon – Hari Seldon Oct 29 '11 at 18:04
  • 1
    Yes, that's what I think. Looking at the web page you are referring to, I think it describes the state of the database upon installation: "This section is the overview of all the tables created during the WordPress standard installation." – Simon Ouellette Oct 29 '11 at 18:08
0

From Mysql

Cardinality

An estimate of the number of unique values in the index. This is updated by running ANALYZE TABLE or myisamchk -a. Cardinality is counted based on statistics stored as integers, so the value is not necessarily exact even for small tables. The higher the cardinality, the greater the chance that MySQL uses the index when doing joins

So, it's just an estimate of the number of unique values in an index and isn't necessarily exact. It really just means, you probably have no chance of mysql using an index, probably because you have no data for Mysql to index on.

Taken from that Wordpress link:

The following are the specific fields in each of the tables created during the standard WordPress installation.

There is no data in this table on install, so there is nothing for MySql to index upon.

stevebot
  • 23,275
  • 29
  • 119
  • 181