-1

I have a table which has 55 columns among these columns 16 columns are for text. I am going to use Varchar(170) for these 16 columns.

Can anybody tell me that if I have 20 record per day its not making my database heavy cause. Database is in back end of my website

Sathyajith Bhat
  • 21,321
  • 22
  • 95
  • 134
user3724705
  • 31
  • 1
  • 5
  • Assuming your mysql database runs on something that performs better than the average 6 year old smartphone you'll be fine – reto Jun 10 '14 at 07:21
  • 20 records .. per day .. uhhhm. (55 columns sounds like much more of a real issue.) – user2864740 Jun 10 '14 at 07:22

2 Answers2

1

As you know, a char() stores a fixed length. If you define char(100), and you know your strings are never going to exceed 20 characters, then you're wasting 80 bytes (or more!) per row.

As you also know, varchar() stores a variable length record. If you define varchar(100), then even of all of strings happen to be 20 characters or less, you're still not "wasting" any space.

Here's the mySQL man documentation:

http://dev.mysql.com/doc/refman/5.0/en/char.html

I'm not sure if this information is all still accurate, but you might also be interested in this link:

What are the optimum varchar sizes for MySQL?

Community
  • 1
  • 1
FoggyDay
  • 11,962
  • 4
  • 34
  • 48
0

Use that length you need for data in the column.

There is no advice for all situations, you always need to work with real (or expected) datas.

And you don´t worry about 20 new rows in database daily, it´s nothing :-)

pavel
  • 26,538
  • 10
  • 45
  • 61
  • ya i only need 170 not more each one – user3724705 Jun 10 '14 at 07:31
  • It doesn´t matter. Till you have millions records in your database than you can begin thinking about records count. – pavel Jun 10 '14 at 07:36
  • 170 means taking each field varchar(170). it doesnt effect performance of databse? – user3724705 Jun 10 '14 at 08:16
  • Till you have millions records, there is no problem with database performance. Of course, with correctly set indexes. If you have only thousands records (hundreds thousand), there will be no problem. – pavel Jun 10 '14 at 08:40