Hola, al hacer un join, explain indica que esta usando el indice de la tabla que tiene el join, cuando ambas tablas tienen indices. Esto hace que el query tarde demasiado en traer lo resultados.
Intenté ya usar un force index sin exito.
Cualquier ayuda u orientación se agradece.
PS:el query y las tablas
select *
from contrato sc
left join booking bok on (`bok`.`num_contrato` = `sc`.`num_contrato`)
CREATE TABLE `booking` (
`ndx_booking` int(10) unsigned NOT NULL AUTO_INCREMENT,
`id_planta` varchar(5) NOT NULL,
`num_booking` varchar(25) NOT NULL,
`num_contrato` varchar(20) NOT NULL,
`f_book` date NOT NULL,
`buque` varchar(30) NOT NULL,
`num_viaje` varchar(15) DEFAULT NULL,
`naviera` int(10) unsigned NOT NULL,
`ETA` date DEFAULT NULL,
`lugar_salida` varchar(45) NOT NULL,
`lugar_llegada` varchar(45) NOT NULL,
`comentarios` text,
`ETD` date NOT NULL,
PRIMARY KEY (`ndx_booking`),
KEY `book_book` (`num_booking`),
KEY `book_naviera` (`naviera`),
KEY `num_contrato` (`num_contrato`)
)
CREATE TABLE `contrato` (
`id_contrato` int(10) unsigned NOT NULL AUTO_INCREMENT,
`cat_clientes_` int(10) unsigned NOT NULL,
`incoterm` varchar(5) NOT NULL,
`num_contrato` varchar(20) NOT NULL,
`precio` varchar(255) DEFAULT NULL,
`destino` varchar(45) NOT NULL,
`f_alta` date NOT NULL,
`f_embarque` varchar(7) DEFAULT NULL,
`term_pago` int(10) unsigned NOT NULL,
`notas` text,
`estado` varchar(3) NOT NULL,
`id_usuario` int(10) unsigned NOT NULL,
`tipo` int(1) unsigned NOT NULL,
`idioma` int(1) unsigned NOT NULL,
`num_cli_cont` varchar(30) DEFAULT ‘ ‘,
`hora_cont` time NOT NULL COMMENT ‘hora de creacion del cotrato’,
`delivery` varchar(80) DEFAULT NULL COMMENT ‘liberacion de documentos’,
PRIMARY KEY (`id_contrato`),
UNIQUE KEY `sc_sc` (`num_contrato`(10)) USING BTREE,
KEY `contrato_FKIndex1` (`incoterm`),
KEY `contrato_FKIndex2` (`cat_clientes_`),
KEY `sc_idUsuario` (`id_usuario`),
KEY `sc_estado` (`estado`),
KEY `sc_f_alta` (`f_alta`),
KEY `sc_tipo` (`tipo`) USING BTREE
)
Leave a Reply
You must be logged in to post a comment.