Web 统计表的数据库字段

发布于 2024-11-28 12:05:45 字数 623 浏览 0 评论 0原文

我需要关于应该为记录访客统计信息的脚本创建哪些数据库字段的建议。

到目前为止,我

ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
os varchar(10) default NULL,
time datetime NOT NULL default '0000-00-00 00:00:00',
ip varchar(40) default NULL,
host varchar(150) default NULL,
browser varchar(50) default NULL,
os varchar(20) default NULL,
referrer text,
search text,
language varchar(5) default NULL,
screenres varchar(15) default NULL,
PRIMARY KEY (ID),
KEY time (time)

基本上想为每次访问记录尽可能多的数据,但同时保持表访问速度快,因为它将有很多记录......

你认为我应该将操作系统+浏览器存储到一个单一的原始格式的字段($_SERVER['HTTP_USER_AGENT'] 的值),并确定输出的操作系统和浏览器?

I need advice on what database fields should I create for a script that records visitor statistics.

So far I have

ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
os varchar(10) default NULL,
time datetime NOT NULL default '0000-00-00 00:00:00',
ip varchar(40) default NULL,
host varchar(150) default NULL,
browser varchar(50) default NULL,
os varchar(20) default NULL,
referrer text,
search text,
language varchar(5) default NULL,
screenres varchar(15) default NULL,
PRIMARY KEY (ID),
KEY time (time)

Basically I want to record as much data as possible for each visit, but at the same time keep the table access fast because it will have many records...

Do you think I should store the os + browser into a single field in raw format (value of $_SERVER['HTTP_USER_AGENT']), and determine the os and browser on output ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

离线来电— 2024-12-05 12:05:45

在这里的任何人都能给你一个更清晰的答案之前,还有很多问题需要回答。

  1. 这一切将用于什么?

  2. 这会记录访问的每个页面还是仅记录访问者的初始“登陆页面”?

另外,是的,您可以将 HTTP_USER_AGENT 存储在一个字段中并在输出时进行处理(如果当时需要),您是否要记录用户在您的页面上停留的时间,以查看是否是错误或他们是否正在阅读它。从那里您可以查看他们是否点击了您网站上的至少一个其他链接。

至于它的存储速度,这在很大程度上取决于您在特定时间内预计有多少访问者,一旦您有了这样的数字,您就可以模拟有多少人访问您的网站,同时看看需要多长时间你会遇到瓶颈。

There is still quite a lot that needs to be answered before anyone here can give you a clearer answer.

  1. What is this all going to be used for?

  2. Is this going to log every page visited or just the initial 'landing page' of the visitor?

Also, yes you could just store the HTTP_USER_AGENT in one field and process on output (if needed at the time), are you going to record how long the user stays on your page to see if it was a mistake or if they are reading it. From there you could look at maybe seeing if they click at least one other link on your site.

As for speed of it storing, well that will heavily depend on how many visitors you expect within a certain period of time, once you have a figure like that you could look at simulating that many people accessing your site whilst seeing how long it takes for you to get a bottleneck.

夏日落 2024-12-05 12:05:45

在我看来,“保持(...)快速访问”和“表”一词不适合放在一个句子中。简单地说,因为与任何专用日志记录方法相比,对数据库的日志记录访问总是很慢。

最好的方法 - 使用脚本引擎的本机日志记录,例如 syslog。

我猜您正在使用 PHP,因此只需调用 fopen()flock()fwrite() 即可轻松实现最佳结果。然后 - 您可以简单地记录有关访问者的几乎所有内容:cookie、get、post、会话、整个服务器数组(仅包含引用者或 ip 等字段)。记录脚本执行时间和脚本错误(如果有)也很有用。

对于我来说,我使用 PHP Log2Files Advanced Logger,它以文本或二进制形式记录 - 这确实是最快的解决方案:)

In my opinion "keep(...)access fast" and the word "table" don't fit in one sentence. Simply, because logging visits to DB is always slow in relation to any dedicated logging method.

Best way - use the native logging for your script engine, for example syslog.

I guess you're using PHP, so best results can be easily achieved with simply fopen() flock() fwrite() calls. Then - you can simply log almost EVERYTHING about your visitor: cookies, get, post, session, whole server array (which simply contain fields like referrer or ip). It's also useful to log script execution time and script errors if any.

As for me, I use PHP Log2Files Advanced Logger, which logs as text or as binary - and this is really fastest solution :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文