Welcome Guest ( Log In | Register )



 
Reply to this topicStart new topic
> Mysql Overhead
khalilov
post Oct 4 2008, 01:55 PM
Post #1


Advanced Member
Group Icon

Group: [HOSTED]
Posts: 197
Joined: 17-July 08
From: Atlantis
Member No.: 31,503
myCENTs:51.68



Sometimes in a table especially if i do alot of things in it i start seeing overhead then a size near it? what is overhead? and is it essential to optimize the table to fix it? I know its just a press of a button but i'd like to know what happens when i optimize a table.

Also when you make a new table you can limit the size of VARCHAR to a number, that number would be the number characters allowed in that column per entry. I'd like to know how the limit works for texts, is it in KB? or number of characters? Cuz i made a messaging system. And i remember reading somewhere here that each text takes 65kb, thats too much for a simple message in a game. 500 MB is a lot of space, but that doesnt mean it has to be wasted =)
Go to the top of the page
 
+Quote Post
faulty.lee
post Oct 4 2008, 02:56 PM
Post #2


Super Member
Group Icon

Group: [HOSTED]
Posts: 500
Joined: 5-November 06
Member No.: 17,016
myCENTs:NEGATIVE[-20.12]



QUOTE(khalilov @ Oct 4 2008, 09:55 PM) *
Sometimes in a table especially if i do alot of things in it i start seeing overhead then a size near it? what is overhead? and is it essential to optimize the table to fix it? I know its just a press of a button but i'd like to know what happens when i optimize a table.

Also when you make a new table you can limit the size of VARCHAR to a number, that number would be the number characters allowed in that column per entry. I'd like to know how the limit works for texts, is it in KB? or number of characters? Cuz i made a messaging system. And i remember reading somewhere here that each text takes 65kb, thats too much for a simple message in a game. 500 MB is a lot of space, but that doesnt mean it has to be wasted =)

If you set TEXT as your data type for that column, it allows you to store up to 65535 character, which is 64KBytes (1K = 1024), if everything is in ASCII. If you're storing unicode or UTFX(8,16,32), it could be more than that, up to 3 bytes per character. Where as VARCHAR allows a maximum of 255 characters, or less if you specified the limit. If you try to update or insert text longer that the limit you specified, then it will return an error.

These are maximum length of text you can store, but it doesn't mean it will take up that much storage if you use only partially. As mentioned in MySQL's documentation, VARCHAR as an overhead of 1 byte, where as TEXT has 2 bytes. So if you store 10 ASCII character in TEXT, it will take up 12 bytes altogether, not 64KB.
Go to the top of the page
 
+Quote Post
khalilov
post Oct 4 2008, 05:36 PM
Post #3


Advanced Member
Group Icon

Group: [HOSTED]
Posts: 197
Joined: 17-July 08
From: Atlantis
Member No.: 31,503
myCENTs:51.68



oh in that case i'll keep it as text, is it necessary to optimize a table when i get overhead?
Go to the top of the page
 
+Quote Post
TavoxPeru
post Oct 8 2008, 05:27 AM
Post #4


Super Member
Group Icon

Group: [HOSTED]
Posts: 805
Joined: 8-April 06
From: Lima - Peru
Member No.: 12,579
myCENTs:46.87



If you have made many changes to a table the data file starts to get fragmented and unused space begins to appear, or if you have deleted some records of a table subsequent INSERT operations reuse this old record positions because the deleted records are mantained in a linked list, so, when this happens you should use the OPTIMIZE TABLE command to reclaim this unused space and to defragment the data file.

The OPTIMIZE TABLE command repairs the table if it has deleted or split rows, sort the index pages if them are not sorted, and update the table's statistics if them are not up to date.

According to the MySql documentation you need to run the OPTIMIZE TABLE command once a week or month only if it is necesary.

My recomendation is to use and run the OPTIMIZE TABLE command every time is needed because it is better to have your tables up to date and in a healthy condition.

So, my answer is yes, it is necessary to optimize your table.

Best regards,
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. MySQL - Trouble With Bulk Insert Statements(3)
  2. MySQL Realtime Replication(4)
  3. Recover Tables From A MySQL .frm File(8)
  4. Mirror My MySQL Database To Another Mysql Server(4)
  5. How To Connect MySQL With Flash?(8)
  6. MySQL Output Database Question(18)
  7. MySQL, Multiple Tables(24)
  8. Navcat For MySQL(9)
  9. Permission Problem With Mysql Database Creation(8)
  10. Mysql And Php(15)
  11. Login System Using A Mysql Db(5)
  12. Oracle Vs. Mysql Vs. Postgresql(9)
  13. Subqueries In Mysql(1)
  14. Apache Php With Mysql On Windows [solved](9)
  15. Not Understanding Mysql(4)
  1. Mysql Script Help(3)
  2. Mysql - So Hard(14)
  3. Mysql Problem(1)
  4. Sun Bought Mysql(6)
  5. Mysql Backup With Another Address?(4)
  6. I Have An Error With My Mysql Connection(7)
  7. Mysql And User File_priv(0)
  8. Mysql Database Management(1)
  9. Mysql Database Entry By Excel Sheets(2)
  10. Mysql On Computer(9)
  11. Any Website Provide Free Host Mysql Host?(4)
  12. Mysql Multiple Tables(1)
  13. Login System(6)


 



- Lo-Fi Version Time is now: 5th December 2008 - 01:35 AM