doutu1939 2016-10-10 16:10
浏览 75
已采纳

如何在mysql中管理每日5000记录插入更新?

I am creating school attendance project using PHP MYSQL and there are 5000 student in school. Daily 5000 record are inserted in database So yearly (500x365) = 1825000 records of 1 year.

Everyday mysql database records size increase so how can manage more data. Daily like Absent, Present, Leave ect. status are inserting.

So please help me how can do this best way using PHP MYSQL and easily manage millions of records.

  • 写回答

1条回答 默认 最新

  • douchengjue9892 2016-10-10 16:54
    关注

    Two million (20 lahks of) rows per year is well within the capabilities of MySQL, or any competent RDMS. We usually don't start using the word "huge" until we get near a billion (100 crore of) records.

    But you still have an interesting problem. You're launching a new application, with a very few records in your database. Over the first weeks and months your data base will stop being "small" and start being "medium-sized" as your application is used.

    Here's what you can expect as that happens: Some queries in your application will become slower as the database grows. You need to be vigilant about that, and identify the slow queries. MySQL servers offer a slow query log to help with that. You can read about how to use it.

    When you identify slow queries, you can then use the EXPLAIN command to give you hints about why they are slow. Slowness in a growing application is usually because you need to add indexes to some of your tables. Just do that. It's probably best to add indexes during off-peak hours. Shortly after you do daily backups of your tables is a good time to do that. (You ARE doing daily backups, correct?)

    If you add the correct choice of index, your slow query will stop being a slow query. That does not mean you can stop being vigilant: the next phase of growth will most likely identify another slow query.

    In the lingo of computer science, some queries in your application take O(n) time, where n is the number of rows in some table. Others will take O(n-squared) or worse. When n is a small number, you simply don't notice this. But as n grows, these queries become bottlenecks for your users' performance. DBMS software is very good at coping with this kind of inefficiency by using indexes on tables. So, you need to add the necessary indexes when you identify the bottleneck queries.

    It is very difficult, even for highly experienced people, to predict which queries will become slow as a new application grows. At the same time, adding a lot of indexes as insurance against slowdowns doesn't usually help. So this need for vigilance is not a failing on your part: it's simply part of operating a database application.

    Some companies and organizations employ database administrators (DBAs) to do this kind of work. If you have access to a DBA, take advantage of that.

    In the meantime, read http://use-the-index-luke.com/ to get an understanding of how these indexes work.

    And, congratulations on launching an application that will grow! It's big deal.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 组策略中的计算机配置策略无法下发
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)
  • ¥50 mac mini外接显示器 画质字体模糊