MySQL Forums
Forum List  »  Spanish

Demora excesiva en una consulta
Posted by: Andres Fariña
Date: September 06, 2013 07:08AM

Actualmente tengo dos tablas con la siguiente estructura:

Tabla Cliente
Mostrando registros 0 - 29 (~37,5061 total, La consulta tardó 0.0004 seg)

Estructura:
CREATE TABLE `BBVATelemarketing`.`Copia` ( `CodCliente` int( 11 ) NOT NULL AUTO_INCREMENT ,
`PrimerNombre` varchar( 100 ) DEFAULT NULL ,
`Origen` varchar( 50 ) DEFAULT NULL ,
`Estado` int( 11 ) DEFAULT NULL ,
`FechaCarga` date DEFAULT NULL ,
`Email` varchar( 200 ) DEFAULT NULL ,
`Asesor` varchar( 50 ) DEFAULT NULL ,
`NroDocumento` varchar( 50 ) DEFAULT NULL ,
`FechaNac` date DEFAULT NULL ,
`DatoAdicional` varchar( 255 ) DEFAULT NULL ,
`ModificaDomicilio` varchar( 255 ) DEFAULT NULL ,
`PrimerApellido` varchar( 50 ) DEFAULT NULL ,
`SegundoNombre` varchar( 50 ) DEFAULT NULL ,
`SegundoApellido` varchar( 50 ) DEFAULT NULL ,
`CheckSexoF` int( 11 ) DEFAULT NULL ,
`CheckSexoM` int( 11 ) DEFAULT NULL ,
`EstadoCivil` varchar( 50 ) DEFAULT NULL ,
`PaisNacimiento` varchar( 50 ) DEFAULT NULL ,
`TipoDocumento` varchar( 50 ) DEFAULT NULL ,
`PaisDocumento` varchar( 50 ) DEFAULT NULL ,
`LugarNacimiento` varchar( 50 ) DEFAULT NULL ,
`CheckResidenteSi` int( 11 ) DEFAULT NULL ,
`CheckResidenteNo` int( 11 ) DEFAULT NULL ,
`CantHijos` int( 11 ) DEFAULT NULL ,
`NivelEducativo` varchar( 50 ) DEFAULT NULL ,
`Profesion` varchar( 50 ) DEFAULT NULL ,
`Actividad` varchar( 50 ) DEFAULT NULL ,
`CheckOtrasTCSi` int( 11 ) DEFAULT NULL ,
`CheckOtrasTCNo` int( 11 ) DEFAULT NULL ,
`DomicilioCalle` varchar( 80 ) DEFAULT NULL ,
`DomicilioNro` varchar( 50 ) DEFAULT NULL ,
`DomicilioApto` varchar( 50 ) DEFAULT NULL ,
`DomicilioBarrio` varchar( 50 ) DEFAULT NULL ,
`DomicilioCP` int( 11 ) DEFAULT NULL ,
`Telefono` varchar( 50 ) DEFAULT NULL ,
`Celular` varchar( 50 ) DEFAULT NULL ,
`DomicilioPais` varchar( 50 ) DEFAULT NULL ,
`DomicilioDpto` varchar( 50 ) DEFAULT NULL ,
`DomicilioLocalidad` varchar( 50 ) DEFAULT NULL ,
`ResideDesde` varchar( 50 ) DEFAULT NULL ,
`CheckPropietarioSi` int( 11 ) DEFAULT NULL ,
`CheckPropietarioNo` int( 11 ) DEFAULT NULL ,
`ValorPropiedadUSD` varchar( 50 ) DEFAULT NULL ,
`GastosAlqu` int( 11 ) DEFAULT NULL ,
`GastosCuotaHip` int( 11 ) DEFAULT NULL ,
`CuotasCredBBVA` int( 11 ) DEFAULT NULL ,
`OtrasCuotas` int( 11 ) DEFAULT NULL ,
`IngresosLiquidos` int( 11 ) DEFAULT NULL ,
`IngresosVariables` int( 11 ) DEFAULT NULL ,
`MayorPlazoOper` varchar( 50 ) DEFAULT NULL ,
`RUTEmpleador` int( 11 ) DEFAULT NULL ,
`RazonSocial` varchar( 50 ) DEFAULT NULL ,
`FechaIngreso` date DEFAULT NULL ,
`DireccionTrabajo` varchar( 120 ) DEFAULT NULL ,
`TelefonoTrabajo` varchar( 50 ) DEFAULT NULL ,
`Cuenta` int( 11 ) DEFAULT NULL ,
`CodigoDomicilio` int( 11 ) DEFAULT NULL ,
`Telefono2` varchar( 50 ) DEFAULT NULL ,
`TipoTarjeta` varchar( 50 ) DEFAULT NULL ,
`TelefonoEnClearing` varchar( 50 ) DEFAULT NULL ,
`DomicilioEnClearing` varchar( 100 ) DEFAULT NULL ,
`DepartamentoClearing` varchar( 50 ) DEFAULT NULL ,
`GRUPO_CLIENTE` varchar( 50 ) DEFAULT NULL ,
`Sucursal` int( 11 ) DEFAULT NULL ,
`NroDireTrabajo` varchar( 50 ) DEFAULT NULL ,
`AptoDireTrabajo` varchar( 50 ) DEFAULT NULL ,
`Referencia1Nombre` varchar( 150 ) DEFAULT NULL ,
`Referencia1Telefono` varchar( 50 ) DEFAULT NULL ,
`Referencia1Direccion` varchar( 200 ) DEFAULT NULL ,
`Referencia2Nombre` varchar( 150 ) DEFAULT NULL ,
`Referencia2Telefono` varchar( 50 ) DEFAULT NULL ,
`Referencia2Direccion` varchar( 200 ) DEFAULT NULL ,
`Referencia3Nombre` varchar( 150 ) DEFAULT NULL ,
`Referencia3Telefono` varchar( 50 ) DEFAULT NULL ,
`Referencia3Direccion` varchar( 200 ) DEFAULT NULL ,
`OfertaFija` int( 11 ) DEFAULT NULL ,
`CheckAlta` int( 11 ) DEFAULT NULL ,
`CheckBaja` int( 11 ) DEFAULT NULL ,
`CheckModificacion` int( 11 ) DEFAULT NULL ,
`CheckVisa` int( 11 ) DEFAULT NULL ,
`CheckMaster` int( 11 ) DEFAULT NULL ,
`CkeckVisaRegional` int( 11 ) DEFAULT NULL ,
`CheckVisaIntern` int( 11 ) DEFAULT NULL ,
`CheckVisaOro` int( 11 ) DEFAULT NULL ,
`CheckCierre4` int( 11 ) DEFAULT NULL ,
`CheckCierre13` int( 11 ) DEFAULT NULL ,
`CheckCierre25` int( 11 ) DEFAULT NULL ,
`CheckMasterRegional` int( 11 ) DEFAULT NULL ,
`CheckMasterIntern` int( 11 ) DEFAULT NULL ,
`CheckMasterOro` int( 11 ) DEFAULT NULL ,
`CheckMasterPlatinum` int( 11 ) DEFAULT NULL ,
`CheckMasterBlack` int( 11 ) DEFAULT NULL ,
`VisaCoBranding` varchar( 50 ) DEFAULT NULL ,
`MasterCoBranding` varchar( 50 ) DEFAULT NULL ,
`LineaTotalVisa` varchar( 50 ) DEFAULT NULL ,
`LineaTotalMaster` varchar( 50 ) DEFAULT NULL ,
`Campania` varchar( 50 ) DEFAULT NULL ,
`EmitirEstCuenta` int( 11 ) DEFAULT NULL ,
`NoEmitirEstCuenta` int( 11 ) DEFAULT NULL ,
`EntregarTCDomicilio` int( 11 ) DEFAULT NULL ,
`EntregarTCSucurs` int( 11 ) DEFAULT NULL ,
`SucursalEntrega` varchar( 80 ) DEFAULT NULL ,
`DebitarPesosCuenta` varchar( 50 ) DEFAULT NULL ,
`DebitarUSDCuenta` varchar( 50 ) DEFAULT NULL ,
`SubCuentaPesosNro` varchar( 50 ) DEFAULT NULL ,
`SubCuentaUSDNro` varchar( 50 ) DEFAULT NULL ,
`PagoMinimoPesos` int( 11 ) DEFAULT NULL ,
`PagoTotalPesos` int( 11 ) DEFAULT NULL ,
`PagoMinimoUSD` int( 11 ) DEFAULT NULL ,
`PagoTotalUSD` int( 11 ) DEFAULT NULL ,
`NombreConyuge` varchar( 100 ) DEFAULT NULL ,
`ConyPaisDoc` varchar( 50 ) DEFAULT NULL ,
`ConyTipoDoc` varchar( 50 ) DEFAULT NULL ,
`ConyNroDoc` varchar( 50 ) DEFAULT NULL ,
`ConyIngresosLiq` int( 11 ) DEFAULT NULL ,
`CheckAdicional` int( 11 ) DEFAULT NULL ,
`ConySexoF` int( 11 ) DEFAULT NULL ,
`ConySexoM` int( 11 ) DEFAULT NULL ,
`ConyEstadoCivil` varchar( 50 ) DEFAULT NULL ,
`ConyFechaNac` date DEFAULT NULL ,
`Adic1Nombre1` varchar( 50 ) DEFAULT NULL ,
`Adic1Nombre2` varchar( 50 ) DEFAULT NULL ,
`Adic1Apellido1` varchar( 50 ) DEFAULT NULL ,
`Adic1Apellido2` varchar( 50 ) DEFAULT NULL ,
`Adic1SexoF` int( 11 ) DEFAULT NULL ,
`Adic1SexoM` int( 11 ) DEFAULT NULL ,
`Adic1EstadoCivil` varchar( 50 ) DEFAULT NULL ,
`Adic1FechaNac` date DEFAULT NULL ,
`Adic1TipoDoc` varchar( 50 ) DEFAULT NULL ,
`Adic1PaisDoc` varchar( 50 ) DEFAULT NULL ,
`Adic1NroDoc` varchar( 50 ) DEFAULT NULL ,
`Adic2Nombre1` varchar( 50 ) DEFAULT NULL ,
`Adic2Nombre2` varchar( 50 ) DEFAULT NULL ,
`Adic2Apellido1` varchar( 50 ) DEFAULT NULL ,
`Adic2Apellido2` varchar( 50 ) DEFAULT NULL ,
`Adic2SexoF` int( 11 ) DEFAULT NULL ,
`Adic2SexoM` int( 11 ) DEFAULT NULL ,
`Adic2EstadoCivil` varchar( 50 ) DEFAULT NULL ,
`Adic2FechaNac` date DEFAULT NULL ,
`Adic2TipoDoc` varchar( 50 ) DEFAULT NULL ,
`Adic2PaisDoc` varchar( 50 ) DEFAULT NULL ,
`Adic2NroDoc` varchar( 50 ) DEFAULT NULL ,
`CoDeudorNombre1` varchar( 50 ) DEFAULT NULL ,
`CoDeudorNombre2` varchar( 50 ) DEFAULT NULL ,
`CoDeudorApellido1` varchar( 50 ) DEFAULT NULL ,
`CoDeudorApellido2` varchar( 50 ) DEFAULT NULL ,
`CoDeudorSexoF` int( 11 ) DEFAULT NULL ,
`CoDeudorSexoM` int( 11 ) DEFAULT NULL ,
`CoDeudorEstadoCivil` varchar( 50 ) DEFAULT NULL ,
`CoDeudorFechaNac` date DEFAULT NULL ,
`CoDeudorTipoDoc` varchar( 50 ) DEFAULT NULL ,
`CoDeudorPaisDoc` varchar( 50 ) DEFAULT NULL ,
`CoDeudorNroDoc` varchar( 50 ) DEFAULT NULL ,
`CoDeudorNacionalidad` varchar( 50 ) DEFAULT NULL ,
`CoDeudorTelefono` varchar( 50 ) DEFAULT NULL ,
`CoDeudorDomicilio` varchar( 50 ) DEFAULT NULL ,
`CoDeudorParentesco` varchar( 50 ) DEFAULT NULL ,
`CoDeudorIngresosLiq` int( 11 ) DEFAULT NULL ,
`AsesorGestion` varchar( 50 ) DEFAULT NULL ,
`FechaCargaProducto` date DEFAULT NULL ,
`CheckTarjetaFija` int( 11 ) DEFAULT NULL ,
`Nombre2Conyuge` varchar( 50 ) DEFAULT NULL ,
`Apellido1Conyuge` varchar( 50 ) DEFAULT NULL ,
`Apellido2Conyuge` varchar( 50 ) DEFAULT NULL ,
PRIMARY KEY ( `CodCliente` ) ,
UNIQUE KEY `NroDocumento` ( `NroDocumento` ) ) ENGINE = InnoDB DEFAULT CHARSET = latin1;

Por otro lado tengo la tabla Contacto
Mostrando registros 0 - 29 (~46,8861 total, La consulta tardó 0.0003 seg)

Estructura:
CREATE TABLE `BBVATelemarketing`.`Copia` ( `CodContacto` int( 11 ) NOT NULL AUTO_INCREMENT ,
`CodCliente` int( 6 ) DEFAULT NULL ,
`Fecha` date DEFAULT NULL ,
`Hora` time DEFAULT NULL ,
`Asesor` varchar( 50 ) DEFAULT NULL ,
`Resultado` varchar( 50 ) DEFAULT NULL ,
`FechaPend` date DEFAULT NULL ,
`Observaciones` varchar( 255 ) DEFAULT NULL ,
`TipoResultado` varchar( 50 ) DEFAULT NULL ,
`BaseOrigen` varchar( 50 ) DEFAULT NULL ,
`Cuenta` int( 11 ) DEFAULT NULL ,
PRIMARY KEY ( `CodContacto` ) ,
KEY `CodCliente` ( `CodCliente` ) ) ENGINE = InnoDB DEFAULT CHARSET = utf8;

Necesito correr esta consulta :
SELECT Cliente.CodCliente, Contacto.CodCliente FROM Cliente INNER JOIN Contacto ON Cliente. CodCliente = Contacto.CodCliente WHERE Contacto.CodContacto IN ( Select MAX(CodContacto) FROM Contacto GROUP BY CodCliente)

La consulta , como resultado de mysql arroja esto :
"Mostrando registros 0 - 29 (18,249 total, La consulta tardó 0.6682 seg)"
Pero este tiempo no es real ya que tarda mas de 20 minutos en mostrar los resultados.

Mi consulta es, que puedo modificar en tablas o que esta mal de la consulta para que esta consulta tarde menos en traer los resultados ?

Gracias

Options: ReplyQuote


Subject
Views
Written By
Posted
Demora excesiva en una consulta
3755
September 06, 2013 07:08AM
1161
September 06, 2013 02:05PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.