0

I am having the query with database.

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?

  • Use indexes properly adn joins. HOwever, if you are designing a large database, you need to hire a database sepcialist to do the design. THis is NOT something a beginner can effectively do or an application programmer who is not a database specialist. At least 10 years of high performance large database (terrabyte size) experience is needed. – HLGEM May 28 '15 at 19:38

2 Answers2

1

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.

Israel Menis
  • 154
  • 5
0

Can you provide more details of the scenario you have? Is the database in a server? which database technology are you using? Is the data saved for a long period of time?

I would suggest you to start looking to indexes one or two of you columns, but maybe is not the right approach for your particular solution.

Israel Menis
  • 154
  • 5
  • I am using MYSQL database on a LAMP server..the data which is going to be save is required throughout the lifetime of user on the application..so data is saved for a long period of time..can you please suggest me solution? – priyanka chordiya Mar 23 '15 at 19:01
  • 1
    this might be useful http://stackoverflow.com/questions/5451190/60-million-entries-select-entries-from-a-certain-month-how-to-optimize-databas – tausif Mar 23 '15 at 19:04