MySQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMySQL Help
Receive the tools necessary to be the rock star of your field. Our 12-month program teaches you the evolving world of multi-channel marketing as well as the complex issues and opportunities found in the industry.

ASP Free and Iron Speed Designer are giving away $5,500+ in FREE licenses. Iron Speed's RAD CASE toolset can save up to 80% of your coding time. One free license per week, one perpetual license per month!
Download and Activate to enter!

Web development can be a daunting task, even for specialists. There is a lot of information to absorb and a lot of technologies to learn in order to manage a superior website. When trying to learn the ropes, developers need a reliable source to introduce new ideas that can be easily implemented. When working on large projects, even web veterans may run into a technology or an aspect of a technology that they are unfamiliar with.

Learn More!


Download to Enter
| Contest Rules

Tutorials | Forums

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 6th, 2012, 06:21 AM
dadli dadli is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2012
Location: Tbilisi, georgia
Posts: 11 dadli User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 43 m 38 sec
Reputation Power: 0
Partition, How to divide the table into 1000 part

Hello
There is a table, into the table is a field id
It is expected that, in this table awaken 1 billion REC.
I want to divide (through partition) this table so that:
Everi part contained one million REC.
I make this so:

PARTITION BY RANGE(id) (
PARTITION p_1 VALUES LESS THAN(1000000),
PARTITION p_2 VALUES LESS THAN(2000000),
PARTITION p_3 VALUES LESS THAN(3000000),
.................
...........



But, I have done this 1000 times by hand.
Question: This is single variant?
There is no way to do this automatically?
Thanks

Reply With Quote
  #2  
Old February 7th, 2012, 01:46 AM
sr sr is offline
Problem Solver
Dev Shed Specialist (4000 - 4499 posts)
 
Join Date: Jan 2001
Location: Stockholm, Sweden
Posts: 4,314 sr User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)sr User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)sr User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)sr User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)sr User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)sr User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)sr User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)sr User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)sr User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)sr User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)sr User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 3 Days 12 h 26 m 54 sec
Reputation Power: 448
You could write a script in your favorite scripting language that outputs the SQL statements instead of writing each by hand.

Also just curious how far away in time are you planning to reach 1,000,000,000 records? Because you don't have to create all partitions right now but instead as you go along and I've heard to many times that -"we need to plan for 500 million rows" and they never reach even 1 million.

Also how large is one record? Do you really need to cap it at 1 million, can't you allow 10 million instead.
__________________
/Stefan

Reply With Quote
  #3  
Old February 8th, 2012, 04:00 AM
dadli dadli is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2012
Location: Tbilisi, georgia
Posts: 11 dadli User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 43 m 38 sec
Reputation Power: 0
All clearly, thanks so much for answer

Reply With Quote
  #4  
Old February 8th, 2012, 05:24 AM
dadli dadli is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2012
Location: Tbilisi, georgia
Posts: 11 dadli User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 43 m 38 sec
Reputation Power: 0
I divided table on two parts, but MySQL scanning full table

Hello.
I write this query:

CREATE TABLE qwe(
id INT NOT NULL AUTO_INCREMENT,
name VARCHAR(50) NOT NULL,
PRIMARY KEY(id)
)

PARTITION BY RANGE(id) (
PARTITION p_1 VALUES LESS THAN(50000),
PARTITION p_2 VALUES LESS THAN(MAXVALUE)
)


After, I insert into the table 100 000 record.
After, I make query with EXPLAIN ()


$res = mysqli_query($db, "EXPLAIN PARTITIONS SELECT name FROM qwe WHERE id > 70000");
while($row = mysqli_fetch_assoc($res)) {
echo $row["partitions"].' , '.$row["rows"].' <br>';
}


resultat:
p_2 , 100000

rezultat from "rows" is 100000.
Question: the table is divided the two parts, but MySQL scanning full table, why?
Please answer me if my question is clearly, this is very Important for me.

Reply With Quote
  #5  
Old February 9th, 2012, 03:47 PM
sr sr is offline
Problem Solver
Dev Shed Specialist (4000 - 4499 posts)
 
Join Date: Jan 2001
Location: Stockholm, Sweden
Posts: 4,314 sr User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)sr User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)sr User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)sr User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)sr User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)sr User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)sr User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)sr User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)sr User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)sr User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)sr User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 3 Days 12 h 26 m 54 sec
Reputation Power: 448
Quote:
Originally Posted by dadli
...
resultat:
p_2 , 100000

rezultat from "rows" is 100000.
Question: the table is divided the two parts, but MySQL scanning full table, why?

No the single "p_2" means that it is only using the p_2 partition.

While the rows value is the total number of rows in the _table_ and has nothing to do with how many rows that has been involved in the execution of the query.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > I divided table on two parts, but MySQL scanning full table


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 - 2012, Jelsoft Enterprises Ltd.

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