Solved

A strategy for storing information in a database

Posted on 2014-12-03
6
64 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 14

Assisted Solution

by:Hamidreza Vakilian
Hamidreza Vakilian earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Button Click 11 22
resizeing PHP image 2 21
XML Data Missing in PHP SimpleXML 8 20
wordpress issue 2 15
This article describes some very basic things about SQL Server filegroups.
Read about achieving the basic levels of HRIS security in the workplace.
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…
The viewer will learn how to count occurrences of each item in an array.

762 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

11 Experts available now in Live!

Get 1:1 Help Now