嗨,我有数据库查询 [英] Hi, I am having the query with database

查看:139
本文介绍了嗨,我有数据库查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有数据库查询。

在我的情况下,每个用户都会有每天5条记录在表中保存。
因此,在10天,他们将有50条记录为一个用户..我有50000用户记录的计数达到50000 * 5 = 25万条记录,每天。
如果我想检索某一天的一个特定的记录为特定的用户,我通过这些许多records.Is它一个正确的做法穿越?
如果没有,如何解决这个?

In my case each user will have daily 5 records to save in a table. So in 10 days, their will be 50 records for one user.. I have 50000 users the count of record goes to 50000*5=250000 records per day. If I want to retrieve a particular record for a particular day for a particular user, I have to traverse through these many records.Is it a right practice? If not, What is the solution for this?

推荐答案

我建议你创建在用户和日期列的索引,你可以看到由tausif建议的链接的详细信息。此外,我建议你避免与查询选择* ...,你应该指定每个查询需要,而不是一开始(*)来检索所有列的列。

I would suggest you to create indexes in the user and date columns, you can see details in the link suggested by tausif. Also I would recommend you to avoid your queries with "select * from ...", you should specify the columns you need in each query rather than a start (*) to retrieve all the columns.

这篇关于嗨,我有数据库查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆