douhuan6305 2014-04-07 09:49
浏览 77

如何在MySql数据库中存储大量记录?

I have a table which consists of around 2500 rows for a single user id. And for each user id, same number of rows will be there. If number of users increase then I am afraid number of rows will be vast.

So can you please suggest me what to do ? Should I use different tables for different users or a single table for all users. And another thing , is there any limitation of how many maximum number rows/columns can be there in a single table ?

My database looks like below structure :

for User1

id ----   col1 
1  ----  value1
2  ----  value2

..............

2500 ---- value 2500

for User2

id ----  col1 ...
1  ----  value1
2  ----  value2

..............

2500 ---- value 2500

likewise it will continue for suppose 1 million users

So, should I go for creating separate tables for each users or should I create 1 table containing all the records.

  • 写回答

1条回答 默认 最新

  • doutan3040 2014-04-07 09:51
    关注

    Use a table as you are. MySQL can easily handle billions or rows of data. With some nice indexes your performance should be quite good as well.

    That's not to say that you shouldn't be looking to ensure that you have good table design, but you also shouldn't be worried about handling what you think is probably loads of data - when in actual fact it is likely a drop in the ocean of datasets.

    The number of columns really doesn't make TOO much difference, the row size can increase the time it takes a hard drive to access them (according to a few articles I have read) but at the same time, you would have to have a REALLY big row to actually notice the difference across thousands of queries.

    As for good structure, it really depends on HOW you will need to use it. If you will be performing many different aggregate functions, ensure you have a table that will allow for it. If you need only a few specific queries, it might be good to create a report specific table that aggregates the data say once per day.

    Edit: Notes on actual limit to number of rows:

    http://dev.mysql.com/doc/refman/5.1/en/source-configuration-options.html

    The MyISAM storage engine supports 2^32 rows per table, but you can build MySQL with the --with-big-tables option to make it support up to 2^64 rows per table.

    http://dev.mysql.com/doc/refman/5.1/en/innodb-restrictions.html

    The InnoDB storage engine doesn't seem to have a limit on the number of rows, but it has a limit on table size of 64 terrabytes. How many rows fits into this depends on the size of each row.

    评论

报告相同问题?

悬赏问题

  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?