| | |
How to store a big database
Please support our MySQL advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
Hi and I have been working on a project involving a rather large database. My question is "For a database with over 20529860 rows, is it better to have 3330 tables spreaded equally or to split into multiple databases or would it be better to have 49950 tables in the database containing the information?" The reason I ask is that having all those rows in the one table makes it really slow with the Where clause and I'm not sure which way is the best way to design this database with mysql. I found that anything over 15MB in one table takes too long to lookup so if I had to guess I would spread it over the 49950 tables ((255-33)*15*15) but sounds like a ridiculous number of tables to store the one set of data. So does anybody have any ideas on how to store potentially 1,000,000,000 rows in mysql. Each row only contains a few bytes. Thanks.
Try not to bump 10 year old threads as it can be really annoying.
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
•
•
Join Date: Dec 2007
Posts: 190
Reputation:
Solved Threads: 25
0
#2 18 Days Ago
•
•
•
•
I found that anything over 15MB in one table takes too long to lookup
Are you properly indexing your tables? For performance, you can split the tables on year/month basis if you have datatime field. Otherwise you can use MySQL 5.1's partitioning.
How many columns do you have in a table?
0
#3 18 Days Ago
Then how many rows do you have and how much cpu? In each of my tables is only 4 text columns and one int column. Also the word NULL occurs as the value most of the time with my current structure if that makes any difference.
So I have 2.66GHz dual core with millions of rows. What are your specs for cpu and num of rows in your large database?
So I have 2.66GHz dual core with millions of rows. What are your specs for cpu and num of rows in your large database?
Try not to bump 10 year old threads as it can be really annoying.
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
•
•
Join Date: Dec 2007
Posts: 190
Reputation:
Solved Threads: 25
0
#4 16 Days Ago
I am dealing with tables with 50+ million rows with much more columns. But they do not contain more than 1 text column. Are columns of type text or varchar?
The performance also depends on the available RAM to MySQL. I have quad core server with 12GB RAM.
How do you seek data (SELECT)? What does you have in your WHERE cluase?
The performance also depends on the available RAM to MySQL. I have quad core server with 12GB RAM.
How do you seek data (SELECT)? What does you have in your WHERE cluase?
0
#5 16 Days Ago
Well basically on my first attempt with I might try a similar approach again was a table of 4 columns just plain text type (not varchar). They all have variable length and I can never seem to get varchar() to work with the number I put in the bracket in phpmyadmin. I think that number might represent the length but I have variable length. Also the length of each cell never exceeds 90 characters. The basic mysql statement I use is as follows:
Just note that I don't always use the characters on the keyboard for the "somevalue" because it is encrypted to use most of the ansci table.
Also I'm testing on a computer with 4GB of ram and I did the math turns out my database failed at around 150 thousand rows. So do you have any ideas on what I should do or what how to set the columns to something better if needed?
Thanks.
mysql Syntax (Toggle Plain Text)
SELECT * FROM `table` WHERE `col1`="somevalue"
Also I'm testing on a computer with 4GB of ram and I did the math turns out my database failed at around 150 thousand rows. So do you have any ideas on what I should do or what how to set the columns to something better if needed?
Thanks.
Try not to bump 10 year old threads as it can be really annoying.
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
•
•
Join Date: Dec 2007
Posts: 190
Reputation:
Solved Threads: 25
0
#6 13 Days Ago
Creating a table with VARCHAR columns of a specified length is very easy. e.g
Otherwise you can change the current table column types to VARCHAR with the following command. Keeping future needs in the mind, I have making varchar columns of length 150. You can adjust them according to your needs. The following query will take a long time according to your table size.
Do you have an IDEX on col1? Creating an index on this column will enhance the performance.
ALTER TABLE `table_data` ADD INDEX ( `col1` );
mysql Syntax (Toggle Plain Text)
CREATE TABLE `table_data` ( `col1` VARCHAR( 150 ) NOT NULL , `col2` VARCHAR( 150 ) NOT NULL , `col3` VARCHAR( 150 ) NOT NULL , `col4` VARCHAR( 150 ) NOT NULL ) ENGINE = MYISAM ;
Otherwise you can change the current table column types to VARCHAR with the following command. Keeping future needs in the mind, I have making varchar columns of length 150. You can adjust them according to your needs. The following query will take a long time according to your table size.
mysql Syntax (Toggle Plain Text)
ALTER TABLE `table_data` CHANGE `col1` `col1` VARCHAR( 150 ) NOT NULL, CHANGE `col2` `col2` VARCHAR( 150 ) NOT NULL, CHANGE `col3` `col3` VARCHAR( 150 ) NOT NULL, CHANGE `col4` `col4` VARCHAR( 150 ) NOT NULL;
ALTER TABLE `table_data` ADD INDEX ( `col1` );
0
#7 13 Days Ago
Then for the 150 you used, does that specify the string length? If so then is it possible to have a variable string length where different rows have different lengths?
Try not to bump 10 year old threads as it can be really annoying.
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
•
•
Join Date: Dec 2007
Posts: 190
Reputation:
Solved Threads: 25
0
#8 13 Days Ago
Yes, 150 is the maximum string length that can be strored in this column. This can be any value upto 255 for VARCHAR. You can not manually set the length for each row, MySQL adjust it automatically for VARCHAR. Read the details in MySQL manual.
0
#9 13 Days Ago
I will give it a try and just in case I need to know, what do I do if my string length exceeds 255. Also does the string length effect the storage requirements as in does this make all rows have equal storage size? Thanks for the great helps so far! I'll be back tomorrow.
Try not to bump 10 year old threads as it can be really annoying.
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
![]() |
Similar Threads
- Store checkbox value in database (PHP)
- Store pics in database (PHP)
- Multi Location Store Software database design (VB.NET)
- how to convert images to binary to store in database (Java)
- upload images and store the location in a database (PHP)
- How to Hash and Store in Database (ASP.NET)
Other Threads in the MySQL Forum
- Previous Thread: Get ID from table
- Next Thread: About a SELECT command to execute in my MysQL Database
| Thread Tools | Search this Thread |
agplv3 alfresco amazon api artisticlicense aws bizspark breathalyzer camparingtocolumns cmg communityjournalism contentmanagement contractors copyright count court crm database design developer development distinct drupal dui ec2 email enterprise eudora facebook form foss gartner gnu government gpl greenit groklaw hiring hyperic images innerjoins insert ip joebrockmeier join journalism keyword keywords kickfire law legal license licensing linux maintenance managing mariadb matchingcolumns metron micromanage microsoft microsoftexchange mindtouch montywidenius mozilla multiple music mysql mysqlcolumnupdating mysqldatetimeordermax() mysqlindex mysqlinternalqueries mysqlquery mysqlsearch news open-xchange opendatabasealliance opengovernment opensource oracle penelope php priceupdating query referencedesign reorderingcolumns resultset saas select sharepoint simpledb sourcecode spotify sql sugarcrm syntax techsupport thunderbird transparency virtualization






