Solved

A strategy for storing information in a database

Posted on 2014-12-03
6
65 Views
Last Modified: 2015-01-12
HI

We have a PHP application that stores big quantities of information in some tables, we are considering a couple of solutions in order to improve performance during queries, we want your opinion and suggestions about it:

1. Create a backup table(s) with the old records stored in there, the most important and frequent queries will be used only against the original table.
2. the same solution in previous point but in a different database.

Thanks in advance.
0
Comment
Question by:dimensionav
6 Comments
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 40479809
Interesting question!  Please post the CREATE TABLE scripts so we can see what the tables contain.  Often we can suggest a better design if we know the access patterns to the data.  I'm going to assume that you've got sufficiently powerful servers and you have had a DBA look at the indexing scheme, consider the EXPLAIN SELECT output, etc  (and if you have not done that yet, it's worth a try).
0
 
LVL 58

Expert Comment

by:Gary
ID: 40479823
If the end goal is the data is still on the same server then it doesn't really matter.
A better solution would be to backup the data to a new db and also archive the data seperately away from the server.
0
 
LVL 14

Accepted Solution

by:
Hamidreza Vakilian earned 500 total points
ID: 40483606
I assume that you are going to perform both approaches on the same server.

The most important thing you have to notice, is which storage engine you are going to choose for archiving. Consider using ARCHIVE table if you know you barely query your archive table in the future. ARCHIVE tables use less disk space (it's compressed) but at the price of no indexing. So your queries, each of them will need a full table scan.

If your main table is INNODB, You may think of creating another INNODB table for archiving (disk space won't be reduced this way) . As you know INNODB supports indexing, spliting an INNODB into 2 tables may not significantly affect your query time. That all depends on the number of records in your main table. Is it hundreds, thousands or millions of rows there?

If you know that you are going to frequently query your archived table in the future, maybe the better way is to forget about ARCHIVING, if your record count is not huge.(e.g less than 1 billion).

You need an astute database consult on this to make sure you are taking the best possible solution.

I suggest you to read this article:
http://www.mysqltutorial.org/understand-mysql-table-types-innodb-myisam.aspx

I can help you more if you need more assistance.

Regards
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 14

Assisted Solution

by:Hamidreza Vakilian
Hamidreza Vakilian earned 500 total points
ID: 40483652
You should also consider how many inserts you will perform every day and how often you are planning to archive the main table? Have you thought of locking the table at the time of moving rows from a table to another? Your server may go out of service during the backup process.
0
 

Author Comment

by:dimensionav
ID: 40505920
Ray Paseur:
I apologize for responding so late.
Well, the development department told me that they are  restructuring the database, anyway I will explain the new design:

The system is dedicated to sales and manufacturing, so each Order will have a document called Order Production that will describe each Product of each Order with two characteristics, A) The materials to creat it and B) The steps during manufacturing.

The idea above shows that the registers in the database will be multiplied more less like this:
Orders x Order Production x Products x Materials x Steps of Manufacturing

Situation that will generate a lot of information in those tables.
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 40506002
Would still be helpful to see the CREATE TABLE statements, and if you can give us some idea of the number of columns and rows in each table, we may be able to make some "back-of-the-envelope" estimates.
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now