LINUX.ORG.RU

История изменений

Исправление luntik2012, (текущая версия) :

спасибо, помогло

добавил индекс на поле title:

CREATE TABLE `tracks` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `album_fk` int(11) NOT NULL,
  `genre_fk` int(11) NOT NULL,
  `duration_s` int(11) NOT NULL,
  `title` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `uq_tracks` (`album_fk`,`title`),
  KEY `fk_tracks_genres_idx` (`genre_fk`),
  KEY `tracks_titles_idx` (`title`),
  CONSTRAINT `fk_tracks_albums` FOREIGN KEY (`album_fk`) REFERENCES `albums` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `fk_tracks_genres` FOREIGN KEY (`genre_fk`) REFERENCES `genres` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=66111 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

$ mysqlslap -u root -p"pass  --concurrency=`nproc` --number-of-queries=1000 --create-schema=orpheus --query="select * from tracks where title = '`head /dev/urandom | tr -dc A-Za-z0-9 | head -c 13 ; echo ''`'" --delimiter=";" --verbose --iterations=2 --debug-info
Benchmark
	Average number of seconds to run all queries: 0.024 seconds
	Minimum number of seconds to run all queries: 0.013 seconds
	Maximum number of seconds to run all queries: 0.036 seconds
	Number of clients running queries: 8
	Average number of queries per client: 125


User time 0.02, System time 0.03
Maximum resident set size 5992, Integral resident set size 0
Non-physical pagefaults 483, Physical pagefaults 0, Swaps 0
Blocks in 0 out 0, Messages in 0 out 0, Signals 0
Voluntary context switches 2050, Involuntary context switches 72

Исходная версия luntik2012, :

спасибо, помогло

добавил индекс на поле title:

CREATE TABLE `tracks` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `album_fk` int(11) NOT NULL,
  `genre_fk` int(11) NOT NULL,
  `duration_s` int(11) NOT NULL,
  `title` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `uq_tracks` (`album_fk`,`title`),
  KEY `fk_tracks_genres_idx` (`genre_fk`),
  KEY `tracks_titles_idx` (`title`),
  CONSTRAINT `fk_tracks_albums` FOREIGN KEY (`album_fk`) REFERENCES `albums` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `fk_tracks_genres` FOREIGN KEY (`genre_fk`) REFERENCES `genres` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=66111 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;