Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

To answer your first question about monitoring there are several options.

  1. Slow query log (included with MySQL)

  2. innotop (free)

  3. Jet Profiler (free and enterprise version)

As to your second question, my first thought on optimizing the import would be to create the indexes after you import the data to reduce writes

Create the geodata table

CREATE TABLE `geodata` (
  `trackerId` smallint(5) NOT NULL,
  `time` int(10) unsigned NOT NULL,
  `sats` tinyint(2) unsigned NOT NULL,
  `lat` float(9,6) NOT NULL,
  `lon` float(9,6) NOT NULL,
  `course` smallint(3) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

Then

INSERT DATA

INSERT INTO goedata (trackerid, time, stats, lat, lon, course) values (1,.....)

Then

Create your indexes

CREATE INDEX idx_geodataTrackerID on geodata(trackerId);
CREATE INDEX idx_geodataTime on geodata(time);
CREATE INDEX idx_geodataLat on geodata(lat);
CREATE INDEX idx_geodataLon on geodata(lon);
CREATE INDEX geodataCourse on geodata(course);

It is usually faster to create indexes after data is imported.

http://stackoverflow.com/questions/3688731/is-it-better-to-create-an-index-before-filling-a-table-with-data-or-after-the-dhttps://stackoverflow.com/questions/3688731/is-it-better-to-create-an-index-before-filling-a-table-with-data-or-after-the-d

Craig

To answer your first question about monitoring there are several options.

  1. Slow query log (included with MySQL)

  2. innotop (free)

  3. Jet Profiler (free and enterprise version)

As to your second question, my first thought on optimizing the import would be to create the indexes after you import the data to reduce writes

Create the geodata table

CREATE TABLE `geodata` (
  `trackerId` smallint(5) NOT NULL,
  `time` int(10) unsigned NOT NULL,
  `sats` tinyint(2) unsigned NOT NULL,
  `lat` float(9,6) NOT NULL,
  `lon` float(9,6) NOT NULL,
  `course` smallint(3) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

Then

INSERT DATA

INSERT INTO goedata (trackerid, time, stats, lat, lon, course) values (1,.....)

Then

Create your indexes

CREATE INDEX idx_geodataTrackerID on geodata(trackerId);
CREATE INDEX idx_geodataTime on geodata(time);
CREATE INDEX idx_geodataLat on geodata(lat);
CREATE INDEX idx_geodataLon on geodata(lon);
CREATE INDEX geodataCourse on geodata(course);

It is usually faster to create indexes after data is imported.

http://stackoverflow.com/questions/3688731/is-it-better-to-create-an-index-before-filling-a-table-with-data-or-after-the-d

Craig

To answer your first question about monitoring there are several options.

  1. Slow query log (included with MySQL)

  2. innotop (free)

  3. Jet Profiler (free and enterprise version)

As to your second question, my first thought on optimizing the import would be to create the indexes after you import the data to reduce writes

Create the geodata table

CREATE TABLE `geodata` (
  `trackerId` smallint(5) NOT NULL,
  `time` int(10) unsigned NOT NULL,
  `sats` tinyint(2) unsigned NOT NULL,
  `lat` float(9,6) NOT NULL,
  `lon` float(9,6) NOT NULL,
  `course` smallint(3) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

Then

INSERT DATA

INSERT INTO goedata (trackerid, time, stats, lat, lon, course) values (1,.....)

Then

Create your indexes

CREATE INDEX idx_geodataTrackerID on geodata(trackerId);
CREATE INDEX idx_geodataTime on geodata(time);
CREATE INDEX idx_geodataLat on geodata(lat);
CREATE INDEX idx_geodataLon on geodata(lon);
CREATE INDEX geodataCourse on geodata(course);

It is usually faster to create indexes after data is imported.

https://stackoverflow.com/questions/3688731/is-it-better-to-create-an-index-before-filling-a-table-with-data-or-after-the-d

Craig

Source Link
Craig Efrein
  • 9.7k
  • 12
  • 62
  • 97

To answer your first question about monitoring there are several options.

  1. Slow query log (included with MySQL)

  2. innotop (free)

  3. Jet Profiler (free and enterprise version)

As to your second question, my first thought on optimizing the import would be to create the indexes after you import the data to reduce writes

Create the geodata table

CREATE TABLE `geodata` (
  `trackerId` smallint(5) NOT NULL,
  `time` int(10) unsigned NOT NULL,
  `sats` tinyint(2) unsigned NOT NULL,
  `lat` float(9,6) NOT NULL,
  `lon` float(9,6) NOT NULL,
  `course` smallint(3) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

Then

INSERT DATA

INSERT INTO goedata (trackerid, time, stats, lat, lon, course) values (1,.....)

Then

Create your indexes

CREATE INDEX idx_geodataTrackerID on geodata(trackerId);
CREATE INDEX idx_geodataTime on geodata(time);
CREATE INDEX idx_geodataLat on geodata(lat);
CREATE INDEX idx_geodataLon on geodata(lon);
CREATE INDEX geodataCourse on geodata(course);

It is usually faster to create indexes after data is imported.

http://stackoverflow.com/questions/3688731/is-it-better-to-create-an-index-before-filling-a-table-with-data-or-after-the-d

Craig