| What is the Maximum Number of Content Items in Joomla! 1.5? |
| Monday, 10 November 2008 09:43 |
|
Someone once asked me, "How many content items can we have in Joomla!?" Without hesitation, I said, "There is no limit". In that back of my head, I knew that was not 100% true. After a little research, I have my answer… Now, I could tell you that the maximum is: "4,294,967,295", but what fun would that be? I'm not in the habit of creating lame blog posts, so I'll continue and show you how we come up with that number. Even though I am writing on Joomla! 1.5.x, this exact same information pertains to Joomla! 1.0.x. I am going to try to break this down as much as possible so that even those without a degree in Computer Science will be able to understand it. Keep your fingers crossed. The first thing we have to do is have an understanding of how Joomla! stores content items in the database. All content in Joomla is stored in a table called, "#__content". When Joomla! executes, it replaces "#__" with your database prefix. Typically, this is "jos_", thus the table storing Joomla!'s content is usually called, "jos_content". Like most database tables, Joomla! uses a field called "id" to identify one content item from another. With that said, we need to take a look at the SQL used to create the jos_content table. It can be found in " installation\sql\mysql\joomla.sql". Here is the snippet that we need to analyze: CREATE TABLE `#__content` ( `id` int(11) unsigned NOT NULL auto_increment, `title` varchar(255) NOT NULL default '', `alias` varchar(255) NOT NULL default '', [omitted for readability] ) TYPE=MyISAM CHARACTER SET `utf8`; I removed a large chunk of the CREATE TABLE statement, since we only care about one line. As you can see above, the "id" field is an unsigned int field. What is an unsigned int field? I thought you would never ask. I think we will just break apart the whole line starting with "id":
I hope I have not lost you yet, because now we are going to analyze just how we get to the magic number. For those who do not want to "think", you can ignore the rest. WARNING: MATH CONTENT… Let's lay out some knowns or truths that we will need in our calculation:
That was fun… moving on: Knowing what we know above, we can derive that 4 bytes = 32 bits. That means that if we take "2" (number of binary values in 1 bit.) to the power of "32" (number of bits in our int field) 2 ^ 32 = 4294967296 But, Kenneth, you said the name was 4294967295. True, I did. However, 2 ^ 32 does not take zero into account. Since zero is a legit value for an unsigned int, our maximum number is in fact: 4294967295 Legit values on an unsigned int field are 0 to 4294967295 That's it. I hope that made sense. The next paragraph just explains signed versus unsigned a little bit and the numbers used do not pertain to Joomla!. It is only intended to educate a little more. So, what is the unsigned part all about? Well, let's say that we wanted to allow for the number to be negative. This would take one of the bits and use it to state positive or negative. This would change our formula from "2 ^ 32" to "2 ^ 31". This makes the maximum be: 2147483648. Thus, taking zero into account, we get a range of ‑2147483648 to 2147483647 MORE INFO: MySQL Numeric Types: Kenneth Crowder has been involved in the Joomla! Community since the days of Mambo. He has volunteered many hours to help out the Open Source Project. He is considered an expert in all things related to Joomla!. He was a Technical Reviewer for Joomla! A Users Guide, as well as another book currently in the editing phase. Learn more about Ken.
Set as favorite
Email This
Hits: 5834 Trackback(0)
Comments (0)
![]() Write comment
|

