Esta es mi consulta original completa:
SELECT nota.cust_id,
nota.enviar,
cust.tel_cust,
cd.nombre_ciu,
state.st
FROM nota,cust,cd,state
WHERE nota_folio=
(
SELECT min(nota_folio)
FROM nota
WHERE nota.cust_id = cust.cust_id
AND cd.id_st = state.st_id
AND cd.id_pais = cust.pais_id
AND cd.id_ciu = cust.id_ciu
AND state.st_id = cust.st_id
AND state.pais_id = cust.pais_id
AND nota.fecha BETWEEN '17/08/1996' AND '10/12/2010')
)
Quedando optimizada de la siguente manera:
Crear un índice en la consulta
Tabla: nota
Indice: fecha
SELECT nota.cust_id,
nota.enviar,
cust.tel_cust,
cd.nombre_ciu,
state.st
FROM nota,cust,cd,state
Where cd.id_st = st.st_id
And cd.id_pais = cust.pais_id
And cd.id_ciu = cust.id_ciu
And state.st_id = cust.pobla_id
And state.pais_id = cust.pais_id
And (nota_folio =
(Select min(nota_folio)
From factura
Where nota.cust_id = cust.cust_id
And nota.fecha BETWEEN '17/08/1996' AND '10/12/2010'))
And nota.fecha BETWEEN '17/08/1996' AND '10/12/2010'
And nota.cust_id = cust.cust_id*
sendyiurquery.com