简体   繁体   English

PHP + MySQL网络统计

[英]PHP + MySQL Web Stats

I wondering what ideas you guys had on the best method of doing some web counters backend. 我想知道你们对做一些Web计数器后端的最佳方法有什么想法。 I will be tracking downloads via PHP, I'm looking at around 1.5 million "downloads" per day and all I will be storing would be "userid" and "downloadid". 我将跟踪通过PHP进行的下载,每天大约有150万次“下载”,而我要存储的只是“ userid”和“ downloadid”。 Possibly time too? 可能还有时间吗? What would the best way be? 最好的方法是什么? At the end of every day should I compile all the duplicate downloadids and make another table that is indexed by "day" and "downloadid" and then add a "count" column? 在每天结束时,我应该编译所有重复的downloadid并制作另一个由“ day”和“ downloadid”索引的表,然后添加“ count”列吗?

Obviously both tables will be very large, after 3 months, I can condense the table to "month" and "downloadid" with "count". 显然,两个表都将非常大,在3个月后,我可以将表压缩为带有“计数”的“ month”和“ downloadid”。 I'm just trying to see if there are any better methods? 我只是想看看是否有更好的方法? Once again, I prefer a PHP/MySQL approach. 再一次,我更喜欢PHP / MySQL方法。

Edit: can I use something like: http://www.infobright.org Obviously I would need to pull up the stats on-demand, but the writing to read is most likely 1000:1 编辑:我可以使用类似以下内容的方法: http : //www.infobright.org显然,我需要按需调出统计数据,但阅读的写作很有可能是1000:1

Thanks, James Hartig 谢谢,James Hartig

I'm not really sure why you want to make multiple tables. 我不太确定为什么要创建多个表。 Are you concerned about the size of the table? 您担心桌子的大小吗?

You probably would be fine just inserting each visit in one table as a row with an id, timestamp and your download ids. 只需将每次访问都插入一个表中并带有ID,时间戳和您的下载ID的行就可以了。 Properly written SQL queries should allow you to pull out data on specific days and times or for specific download ids after the data is inserted by using the WHERE statement in your query. 正确编写的SQL查询应该允许您在查询中使用WHERE语句在插入数据后的特定日期和时间或特定的下载ID中提取数据。

Hope that helps! 希望有帮助!

EDIT : This article runs some tests with 6 billion rows. 编辑本文使用60亿行运行一些测试。 From what I can tell, MySQL is still running fairly quickly even with that large number of rows. 据我所知,即使有这么多行,MySQL仍然运行相当快。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM