MySQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsDatabasesMySQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 13th, 2013, 03:44 PM
ByGoneYrs's Avatar
ByGoneYrs ByGoneYrs is online now
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2012
Location: Southern New Jersey, USA
Posts: 178 ByGoneYrs User rank is Second Lieutenant (5000 - 10000 Reputation Level)ByGoneYrs User rank is Second Lieutenant (5000 - 10000 Reputation Level)ByGoneYrs User rank is Second Lieutenant (5000 - 10000 Reputation Level)ByGoneYrs User rank is Second Lieutenant (5000 - 10000 Reputation Level)ByGoneYrs User rank is Second Lieutenant (5000 - 10000 Reputation Level)ByGoneYrs User rank is Second Lieutenant (5000 - 10000 Reputation Level)ByGoneYrs User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 6 Days 11 h 2 m 8 sec
Reputation Power: 64
Send a message via ICQ to ByGoneYrs Send a message via Yahoo to ByGoneYrs
Partioning question for 5.6

Hello everyone,

Currently I have a (4) huge tables with lots of data within them. Now currently our production databases are 5.0.51a and I know that although Partioning did not come about until 5.1, there is a old school work arround but it means their is great risk of fragmention and rewrite our business code to see the different tables/partions.

So testing 5.6, and enabling partiting support...I also know that in Mysql 5.6 you can only partion by Range, List, Hash, and Key. Now MySQL does not support Date partioning, but you could do Range Partioning and use a column that was; DATE, TIME, or DATETIME.

So here is the describe on one of my tables:


mysql> desc ClosedPeriodActivitySummary;
+-------------+--------------------------------------+------+-----+-------------------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+--------------------------------------+------+-----+-------------------+-------+
| FundId | int(11) | NO | MUL | NULL | |
| BegDate | date | NO | MUL | NULL | |
| EndDate | date | NO | MUL | NULL | |
| Category | enum('CASH','MARKET') | YES | MUL | NULL | |
| ItemName | varchar(32) | YES | MUL | NULL | |
| Amount | decimal(16,2) | YES | | NULL | |
| Direction | enum('INFLOW','OUTFLOW','NET-VALUE') | YES | MUL | NULL | |
| LastUpdated | timestamp | NO | | CURRENT_TIMESTAMP | |
+-------------+--------------------------------------+------+-----+-------------------+-------+
8 rows in set (0.01 sec)

So if i wanted to build a Partioned table for this table, and wanted to use RANGE Partioning...and wanted to base the Partions off the column EndDATE which is data type 'YYYY-MM-DD', and I wanted say the parttions to be named for the last day of each month for 2012 and 2013 (24) total

It would look like the following:

create table ClosedPeriodActivitySummary (
(column one),
BegDate date null,
EndDate null,
(column four),
(column five),
(column six),
(coulmn seven),
(column eight)
)

PARTITION BY RANGE (EndDate) (
PARTITION jan2012 VALUE LESS THAN (2012-01-31),
PARTITION feb2012 VALUE LESS THAN (2012-02-28),
PARTITION mar2012 VALUE LESS THAN (2012-02-31),

(many more monthly partitions until)
PARTITION dec2013 VALUE LESS THAN (2013-12-31)
);

Is that basically correct?

Next under this setup what happens if someone does a query from a specific partition say feb2012 which would have any entry from date 2012-02-01 till 2012-02-28. Now say they only wanted from the specific date of 2012-02-15, would they just get entrys from just that specific date of the 15th or would they get all entrys from within the partition from the 1st through the 28th?

Reply With Quote
  #2  
Old February 14th, 2013, 10:49 AM
Guelphdad's Avatar
Guelphdad Guelphdad is offline
Hockey face
Dev Shed God 7th Plane (8000 - 8499 posts)
 
Join Date: Nov 2001
Location: St. Catharines, Canada
Posts: 8,141 Guelphdad User rank is General 5th Grade (Above 100000 Reputation Level)Guelphdad User rank is General 5th Grade (Above 100000 Reputation Level)Guelphdad User rank is General 5th Grade (Above 100000 Reputation Level)Guelphdad User rank is General 5th Grade (Above 100000 Reputation Level)Guelphdad User rank is General 5th Grade (Above 100000 Reputation Level)Guelphdad User rank is General 5th Grade (Above 100000 Reputation Level)Guelphdad User rank is General 5th Grade (Above 100000 Reputation Level)Guelphdad User rank is General 5th Grade (Above 100000 Reputation Level)Guelphdad User rank is General 5th Grade (Above 100000 Reputation Level)Guelphdad User rank is General 5th Grade (Above 100000 Reputation Level)Guelphdad User rank is General 5th Grade (Above 100000 Reputation Level)Guelphdad User rank is General 5th Grade (Above 100000 Reputation Level)Guelphdad User rank is General 5th Grade (Above 100000 Reputation Level)Guelphdad User rank is General 5th Grade (Above 100000 Reputation Level)Guelphdad User rank is General 5th Grade (Above 100000 Reputation Level)Guelphdad User rank is General 5th Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 3 Weeks 3 Days 20 h 34 m 13 sec
Reputation Power: 1315
when you say huge, what size is huge? are you partitioning when you don't have to?

Do you have hundreds of millions of rows of data in that specific table for instance?

Reply With Quote
  #3  
Old February 15th, 2013, 09:00 AM
ByGoneYrs's Avatar
ByGoneYrs ByGoneYrs is online now
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2012
Location: Southern New Jersey, USA
Posts: 178 ByGoneYrs User rank is Second Lieutenant (5000 - 10000 Reputation Level)ByGoneYrs User rank is Second Lieutenant (5000 - 10000 Reputation Level)ByGoneYrs User rank is Second Lieutenant (5000 - 10000 Reputation Level)ByGoneYrs User rank is Second Lieutenant (5000 - 10000 Reputation Level)ByGoneYrs User rank is Second Lieutenant (5000 - 10000 Reputation Level)ByGoneYrs User rank is Second Lieutenant (5000 - 10000 Reputation Level)ByGoneYrs User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 6 Days 11 h 2 m 8 sec
Reputation Power: 64
Send a message via ICQ to ByGoneYrs Send a message via Yahoo to ByGoneYrs
Sorry it took so long to get back to you but my youngest son came down with the flue and I came down with a nasty cold(not the flue).

Ok to answer the size qestion for a one month time on the four tables:

mysql> select count(*) from ClosedPeriodActivitySummary where BegDate between '2013-01-01' and '2013-01-31';
+----------+
| count(*) |
+----------+
| 3120 |
+----------+
*** Avg_row_length 89


mysql> select count(*) from ClosedPeriodBalancesSummary where BegDate between '2013-01-01' and '2013-01-31';
+----------+
| count(*) |
+----------+
| 2232 |
+----------+
*** Avg_row_length 139


mysql> select count(*) from ClosedPeriodPositions where PeriodBeginDate between '2013-01-01' and '2013-01-31';
+----------+
| count(*) |
+----------+
| 11668 |
+----------+
*** Avg_row_length 912

mysql> select count(*) from ClosedPeriodTransactions where PeriodBeginDate between '2013-01-01' and '2013-01-31';
+----------+
| count(*) |
+----------+
| 76079 |
+----------+
*** Avg_row_length 942


So the stats for a average 30 days period is:
3120 x 89 = 277689 bytes ~ 0.26482 MB
2232 x 139 = 310248 bytes ~ 0.29588 MB
116688 x 912 = 106419456 bytes ~ 101.4895 MB
76079 x 942 = 71666418 bytes ~ 69.34642 MB

Total in MB for One Month Average is 171.39662 MB

then times say 2 years of data would be:
171.39662 MB x 24 = 4113.51888 MB

now that all adds up if it was just in FOUR tables, but it would be best to partion the four tables via RANGE and then reference a column that is a DATE and break the partitions down into months.

Was my above syntax correct?

Last edited by ByGoneYrs : February 15th, 2013 at 09:02 AM.

Reply With Quote
  #4  
Old February 15th, 2013, 10:53 AM
sr sr is offline
Problem Solver
Dev Shed Specialist (4000 - 4499 posts)
 
Join Date: Jan 2001
Location: Stockholm, Sweden
Posts: 4,434 sr User rank is Colonel (50000 - 60000 Reputation Level)sr User rank is Colonel (50000 - 60000 Reputation Level)sr User rank is Colonel (50000 - 60000 Reputation Level)sr User rank is Colonel (50000 - 60000 Reputation Level)sr User rank is Colonel (50000 - 60000 Reputation Level)sr User rank is Colonel (50000 - 60000 Reputation Level)sr User rank is Colonel (50000 - 60000 Reputation Level)sr User rank is Colonel (50000 - 60000 Reputation Level)sr User rank is Colonel (50000 - 60000 Reputation Level)sr User rank is Colonel (50000 - 60000 Reputation Level)sr User rank is Colonel (50000 - 60000 Reputation Level)sr User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 8 h 1 m 53 sec
Reputation Power: 532
Quote:
Originally Posted by ByGoneYrs
mysql> select count(*) from ClosedPeriodPositions where PeriodBeginDate between '2013-01-01' and '2013-01-31';
+----------+
| count(*) |
+----------+
| 11668 |
+----------+
*** Avg_row_length 912

...

Since the count above was 11668 it looks like you got this 10x too high:
116688 x 912 = 106419456 bytes ~ 101.4895 MB



Which means that total should be about 80MB per month instead.

Then times say 2 years of data would be:
80MB x 24 = 1920MB

Which means that two years of database can fit in the RAM of my laptop and the biggest table will contain only 200,000 rows.
Which in my opinion is too small to start using Partitioning.
It only makes the solution more complex and really no benefit.


But another suggestions if you haven't already done so use the innodb_file_per_table option. That way you can reclaim space with just a simple ALTER TABLE foo ENGINE=InnoDB; a very good best practice.

And regarding your question:
Quote:
Next under this setup what happens if someone does a query from a specific partition say feb2012 which would have any entry from date 2012-02-01 till 2012-02-28. Now say they only wanted from the specific date of 2012-02-15, would they just get entrys from just that specific date of the 15th or would they get all entrys from within the partition from the 1st through the 28th?

The query always returns the correct result that you queried for regardless of if the table is partitioned or not, the only difference is how it is executed in the background. In a partitioned table when you query on the partition key the database is able to determine by the partition key which partition it should examine and searches only that file for the matching records.

But this is the special case, so unless you basically always search on the partition key or your file sizes are limiting then you don't really benefit from partitioning.

The best of luck to you
__________________
/Stefan

Reply With Quote
  #5  
Old February 15th, 2013, 11:01 AM
ByGoneYrs's Avatar
ByGoneYrs ByGoneYrs is online now
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2012
Location: Southern New Jersey, USA
Posts: 178 ByGoneYrs User rank is Second Lieutenant (5000 - 10000 Reputation Level)ByGoneYrs User rank is Second Lieutenant (5000 - 10000 Reputation Level)ByGoneYrs User rank is Second Lieutenant (5000 - 10000 Reputation Level)ByGoneYrs User rank is Second Lieutenant (5000 - 10000 Reputation Level)ByGoneYrs User rank is Second Lieutenant (5000 - 10000 Reputation Level)ByGoneYrs User rank is Second Lieutenant (5000 - 10000 Reputation Level)ByGoneYrs User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 6 Days 11 h 2 m 8 sec
Reputation Power: 64
Send a message via ICQ to ByGoneYrs Send a message via Yahoo to ByGoneYrs
Quote:
Originally Posted by sr
Which means that total should be about 80MB per month instead.

Then times say 2 years of data would be:
80MB x 24 = 1920MB

Which means that two years of database can fit in the RAM of my laptop and the biggest table will contain only 200,000 rows.
Which in my opinion is too small to start using Partitioning.
It only makes the solution more complex and really no benefit.


But another suggestions if you haven't already done so use the innodb_file_per_table option. That way you can reclaim space with just a simple ALTER TABLE foo ENGINE=InnoDB; a very good best practice.

And regarding your question:

The query always returns the correct result that you queried for regardless of if the table is partitioned or not, the only difference is how it is executed in the background. In a partitioned table when you query on the partition key the database is able to determine by the partition key which partition it should examine and searches only that file for the matching records.

But this is the special case, so unless you basically always search on the partition key or your file sizes are limiting then you don't really benefit from partitioning.

The best of luck to you


That is the current data size, BUT the company intends in adding alot more different Bank's info into those four tables and the size will BLOOM if you understand what I am talking about. Currently it is only 5 banks, and there are like 100 more. Also realize as well, there are hundreds of other tables of all sizes in that same database as well too. These four tables will be used for reporting source base.

Last edited by ByGoneYrs : February 15th, 2013 at 11:08 AM.

Reply With Quote
  #6  
Old February 15th, 2013, 05:15 PM
sr sr is offline
Problem Solver
Dev Shed Specialist (4000 - 4499 posts)
 
Join Date: Jan 2001
Location: Stockholm, Sweden
Posts: 4,434 sr User rank is Colonel (50000 - 60000 Reputation Level)sr User rank is Colonel (50000 - 60000 Reputation Level)sr User rank is Colonel (50000 - 60000 Reputation Level)sr User rank is Colonel (50000 - 60000 Reputation Level)sr User rank is Colonel (50000 - 60000 Reputation Level)sr User rank is Colonel (50000 - 60000 Reputation Level)sr User rank is Colonel (50000 - 60000 Reputation Level)sr User rank is Colonel (50000 - 60000 Reputation Level)sr User rank is Colonel (50000 - 60000 Reputation Level)sr User rank is Colonel (50000 - 60000 Reputation Level)sr User rank is Colonel (50000 - 60000 Reputation Level)sr User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 8 h 1 m 53 sec
Reputation Power: 532
Quote:
Originally Posted by ByGoneYrs
That is the current data size, BUT the company intends in adding alot more different Bank's info into those four tables and the size will BLOOM if you understand what I am talking about.

I wish I had had a penny for every time I've heard that.

Quote:
Originally Posted by ByGoneYrs
Also realize as well, there are hundreds of other tables of all sizes in that same database as well too.

This has no impact whatsoever on the decision if you should partition these four tables or not.
It only tells you that your server could need more CPU/RAM/disk space than if it was only these four tables.

The thing is if you know _guaranteed_ that it will "bloom" to about 10 times the size of what we have discussed previously within the next year (i.e get up to 50 banks within a year), then yes I would probably consider looking at it and see if it could benefit from partitioning.
But I kind of speculate a bit about the past growth rate when I see that you are still running 5.0.51. :P

Summary:
1. I definitely think you should upgrade MySQL from the antique 5.0.51 to 5.6.10 if this is a good time to do it.
2. While doing that watch out for the change in precedence of the comma join syntax which took place in 5.1 (in case you have any of these odd "SELECT ... FROM a,b LEFT JOIN c ON ..." in your application).
3. But I would wait with the partitioning until the size has grown bigger, you can always do it later when you actually need it.

Just my 2c
Take care

Reply With Quote
  #7  
Old February 19th, 2013, 08:09 AM
ByGoneYrs's Avatar
ByGoneYrs ByGoneYrs is online now
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2012
Location: Southern New Jersey, USA
Posts: 178 ByGoneYrs User rank is Second Lieutenant (5000 - 10000 Reputation Level)ByGoneYrs User rank is Second Lieutenant (5000 - 10000 Reputation Level)ByGoneYrs User rank is Second Lieutenant (5000 - 10000 Reputation Level)ByGoneYrs User rank is Second Lieutenant (5000 - 10000 Reputation Level)ByGoneYrs User rank is Second Lieutenant (5000 - 10000 Reputation Level)ByGoneYrs User rank is Second Lieutenant (5000 - 10000 Reputation Level)ByGoneYrs User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 6 Days 11 h 2 m 8 sec
Reputation Power: 64
Send a message via ICQ to ByGoneYrs Send a message via Yahoo to ByGoneYrs
Ok on a couple different issues...

Currently we are using Community Ed 5.0.51a...but if we decide to stay with MySQL we would up grade to MySQL 5.6.10 or above. Now my DEV team wants to move to MariaDB 10.1 and obtain support for MariaDB from a company called SkySQL.

Now the other side of the house(where I am sitting myself) wants to move to Oracle Standard 11.2.0.3 datbases for production and staging with a support contract from Oracle, and I further would like to use PostgreSQL 9.3 and buy the added code extensions and support for PostgreSQl from EnterpriseDB. Their add on add both Materialized views and Standby database to postgreSQL and support as well too. for Dev/TEST. This way we could use DEV/TEST with Postgresql, then try the code in Staging which would be Oracle, and then when all checks out roll into Production which is Oracle.

Everything I have seen and heard from Oracle insiders, they are trying to make MySQL into Oracle Light, with eventually changing it enough to be like Oracle Standard and then just kill off MySQL. If we were to remain, I would rather switch to MariaDB then to stay on MySQL.

We are currently changing our whole Infrastructure and one that get ironed out, then the database side of it will be resolved next.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > Partioning question for 5.6

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap