English 中文(简体)
B. 最佳做法战略
原标题:Best view count strategy

目前,我正在与用户IP、观察日期等数据库中储存每一种观点。 但是,地雷网站的点击量很大,它正在增加数据库的锁定时间并减少性能。

我想在档案中节省1小时,然后更新数据库,但有些人告诉我,我们没有为重负荷地点使用档案。

请建议我这样做的最佳战略。

注:我不需要考虑独特的观点。

问题回答

你的网络服务器记录已经为你追踪大部分数据。

我建议的是,每小时轮换一次记录,然后安排一份工作,编制总分类,在非行储存。

在MySQL直接保存和更新这一信息方面没有任何问题。 每小时3 000次点击率低于每秒1点。 Using Inno 该表的亚洲开发银行储存引擎应当消除锁定问题。 然而,非行有多种选择,需要加以适当配置,以便有效地开展工作——这一点很重要。

根据您的意见 我认为,你所寻求的结构将看一看:

id - page id
type - period length, could be  day ,  week ,  month 
period - date when period starts, could be integer written as YYYYMMDD or YYYYMM 
       - depending on the contents of  type  field
count - hit count for a url over given period

主要关键是<代码>(类型、期限、id)。 有效计算<代码>(id, period)和(类型、期限、编号)的索引:

SELECT * 
FROM ... 
WHERE type= week  
  and period = 20120409 
ORDER BY count DESC

网页制作后,每段时间插入记录,编号为0。

UPDATE table 
SET count = count + 1 
WHERE id = $page_id 
  AND period IN (201204, 20120409) 

它将更新所有三个日、周和月统计记录。

已经有了一个非常有效的假想(尽管你必须利用数据来安排职位等等):BAAW邮政管理处的《意见》。 它把所有物品都储存在后马塔,因此很容易进入并维持每日和其他总合。 我在几个地点使用这一系统,每天有50 000页页面浏览量,而且不会放慢任何事情。





相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签