3

I have a table to storage GPS coordinates with multiple (~30) inserts per second (from 50 different devices) during 12 hours per day, so the table is growing fast, to improve the SELECT speed I was thinking of create a partition in the table by Date or DeviceID.

In that case I will need to add the partitioning keys as primary keys?, how will that affect the insertion performance?

CREATE TABLE `carlocation` (
 `Id` int(11) NOT NULL AUTO_INCREMENT,
 `Date` datetime DEFAULT NULL, 
 `GpsLatitude` double DEFAULT NULL,
 `GpsLongitude` double DEFAULT NULL,
 `DeviceID` int(11) NOT NULL, 
 PRIMARY KEY (`Id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1

The server is a Dual Core Xeon with 2GB RAM. Thanks.

Update: The queries are like

SELECT *
FROM carlocation
 WHERE ((carlocation.DeviceID = 2) AND (carlocation.Date> '2010-01-01') AND (carlocation.Date< '2010-01-02'))

Always quering for ONE device only, in one or multiple days.

RolandoMySQLDBA
185k34 gold badges327 silver badges541 bronze badges
asked Jun 26, 2012 at 12:18
2
  • Very much depends on how your typical query looks like. Could you tell us? Commented Jun 26, 2012 at 12:37
  • True, updated question. Commented Jun 26, 2012 at 12:49

1 Answer 1

1

Your one select needs this "compound" index.

INDEX(DeviceID, Date)

Do you have other queries?

But your question was about PARTITIONing. No advantage, based on what you have said so far.

answered Sep 12, 2012 at 1:15

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.