Я использую текущие данные и примеры SNOMED, и я хочу создать транзитивную таблицу закрытия, но что-то в моих настройках сервера MySQL mysql5.6 терпит неудачу.Код MYSQL для создания таблицы транзитивных замыканий не работает
Для тех, кто не знает, SNOMED - это медицинская база данных. Есть 2.1M отношения и 446697 концепций. Запрос останавливается на второй части - так что, я думаю, у него заканчивается ОЗУ. Но какие настройки я настраиваю и на что? join_buffer_size?
вот код:
DELIMITER ;;
CREATE DEFINER=`snomed`@`localhost` PROCEDURE `createTc`()
BEGIN
drop table if exists tc;
CREATE TABLE tc (
source BIGINT UNSIGNED NOT NULL ,
dest BIGINT UNSIGNED NOT NULL
) ENGINE = InnoDB CHARSET=utf8;
insert into tc (source, dest)
select distinct rel.sourceid, rel.destinationid
from rf2_ss_relationships rel
inner join rf2_ss_concepts con
on rel.sourceid = con.id and con.active = 1
where rel.typeid = 116680003 # IS A relationship
and rel.active = 1;
REPEAT
insert into tc (source, dest)
select distinct b.source, a.dest
from tc a
join tc b on a.source = b.dest
left join tc c on c.source = b.source and c.dest = a.dest
where c.source is null;
set @x = row_count();
select concat('Inserted ', @x);
UNTIL @x = 0 END REPEAT;
create index idx_tc_source on tc (source);
create index idx_tc_dest on tc (dest);
END;;
DELIMITER ;
CREATE TABLE `rf2_ss_relationships` (
`id` bigint(20) unsigned NOT NULL,
`effectiveTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`active` tinyint(4) DEFAULT '1',
`moduleId` bigint(20) unsigned NOT NULL,
`sourceId` bigint(20) unsigned NOT NULL,
`destinationId` bigint(20) unsigned NOT NULL,
`relationshipGroup` bigint(20) unsigned NOT NULL,
`typeId` bigint(20) unsigned NOT NULL,
`characteristicTypeId` bigint(20) unsigned NOT NULL,
`modifierId` bigint(20) unsigned NOT NULL,
PRIMARY KEY (`id`,`effectiveTime`),
KEY `moduleId_idx` (`moduleId`),
KEY `sourceId_idx` (`sourceId`),
KEY `destinationId_idx` (`destinationId`),
KEY `relationshipGroup_idx` (`relationshipGroup`),
KEY `typeId_idx` (`typeId`),
KEY `characteristicTypeId_idx` (`characteristicTypeId`),
KEY `modifierId_idx` (`modifierId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
CREATE TABLE `rf2_ss_concepts` (
`id` bigint(20) unsigned NOT NULL,
`effectiveTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`active` tinyint(4) DEFAULT NULL,
`moduleId` bigint(20) unsigned NOT NULL,
`definitionStatusId` bigint(20) unsigned NOT NULL,
PRIMARY KEY (`id`,`effectiveTime`),
KEY `moduleId_idx` (`moduleId`),
KEY `definitionStatusId_idx` (`definitionStatusId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
я теперь использовать это: https://github.com/WestCoastInformatics/SNOMED-CT-Transitive-Closure сделать транзитивное замыкание в Java, а затем импортировать текстовый файл. он намного быстрее, чем mysql. – pgee70