FTP | CCD | Buscar | Trucos | Trabajo | Foros |
|
Registrarse | FAQ | Miembros | Calendario | Guía de estilo | Temas de Hoy |
|
Herramientas | Buscar en Tema | Desplegado |
#1
|
||||
|
||||
Consulta Super Lenta
Bienvenido Club Delphi, y muchas Felicidades por su nuevo aspecto.
Uso Firebird 1.53 con IBExpert 2006 Buen día tengan compañeros, les informo mi problema, tengo una consulta que tiene la finalidad de Sacar las Ventas Netas = Ventas - (Devoluciones + Notas de Crédito) del Año Actual y el Año Anterior, ahora bien, todo marcha bien hasta toparme con el ORDER BY , del cual quiero ordenar por el TOTAL del Año Actual Descendentemente donde este campo Virtual esta posicionado en el campo 6 de la propia consulta pero si la ejecuto tarda más de 6 minutos, pongo la Sentencia SQL:
Ahora bien, si cambio el Order By a : ORDER BY COALESCE(SUM(F.IMPSIVA),0) DESC tarda 6 Segundos, pero no me ordenará correctamente la consulta debido a que solo estoy ordenando las VENTAS y no estoy considerando las Devoluciones y Notas de Crédito, mi duda es la siguiente: Será lo mismo poner ORDER BY TOTAL DESC que ORDER BY 6 DESC ???? en el primero me marca error que columna no se reconoce, lo que pasa es que la columna virtual TOTAL tiene el importe TOTAL NETO que quiero ordenar, mi objetivo es Disminuir el tiempo de la consulta a 10 ó 20 segundos, espero que alguien me haya entendido, si no estoy a sus ordenes. Nota: Al poner ORDER BY 6 DESC si me hace el ordenamiento correcto pero la consulta es demasiada lenta, con decirles que si quito el ORDER BY 6 DESC y First 20 la consulta tarda 10 Segundos para traerme todos los registros y apenas son 5,000 Registros Se podrá Crear un INDICE TEMPORAL PARA EL CAMPO CALCULADO TOTAL ???? Agradezco cualquier Ayuda. Última edición por AGAG4 fecha: 01-04-2006 a las 18:12:10. Razón: Corrección |
#2
|
|||
|
|||
Hola
Pues Yo Probaria
Última edición por marcoszorrilla fecha: 01-04-2006 a las 22:26:01. |
#3
|
|||
|
|||
Pues Yo Probaria
|
#4
|
|||
|
|||
Pues yo me he perdido !!!!
El primer mensaje se lee, pero los otros dos no hay quien los entienda. Una pregunta, si usas FireBird, por que no pruebas los MDO?? Me parece que iran más rapido. Cita:
Cita:
Prueba dejando el ORDER BY 6, y comprueba si la velocidad es suficiente. Si el DESC es obligatorio en tu caso, lo unico que se me ocurre para ganar velocidad son vistas. |
#5
|
||||
|
||||
ok
Gracias por su tiempo en elaborar sus respuestas, pero he intentado crear vistas, y no puedo como verán uso 3 tablas para determinar las Ventas Netas, donde los campos que estan dentro del Where son IGUALES como el TIPOMOV por lo que para una vista mandarle el VALOR a este campo a cada TABLA ignoro y no tengo ídea como hacerlo, aparte en las vistas no se pueden mandar parámetros como los SP, las vistas son producto de 1 ó varias tablas pero con diferentes campos, espero haberme explicado.
Gracias por su tiempo. |
|
|
Temas Similares | ||||
Tema | Autor | Foro | Respuestas | Último mensaje |
Primera consulta, mas lenta que el caballo del malo | papulo | Conexión con bases de datos | 20 | 23-09-2005 13:46:24 |
Problamas consulta SQL | gabsanar | Firebird e Interbase | 2 | 07-02-2005 09:33:05 |
Consulta muy lenta | Walterdf | Conexión con bases de datos | 2 | 25-08-2004 18:37:57 |
Urgente!!! Problema con Consulta SQL | PaLaSaca | SQL | 2 | 06-05-2004 19:56:50 |
lenta la consulta. | digital | Conexión con bases de datos | 2 | 10-09-2003 15:38:13 |
|