Thread: Queries and views

Queries and views

From
"David Cana"
Date:
Hello!

I have got a view like:

    create view consulta_material as
      select
            material.clave as clave,
            referencia,
            sede.nombre_es as nombre_sede, clave_sede,
            soporte.nombre_es as nombre_soporte, clave_soporte,
            area_materiales.nombre_es as nombre_area_materiales,
clave_area_materia
            autor,
            titulo,
            descripcion,
            fecha_intro, fecha_modificacion

      from material, sede, soporte, area_materiales

      where (material.clave_sede = sede.clave)
            and (material.clave_soporte = soporte.clave)
            and (material.clave_area_materiales = area_materiales.clave);

I´d like to know the performance difference between...

    select * from consulta_material where clave=1;

And...

    select
          material.clave as clave,
          referencia,
          sede.nombre_es as nombre_sede, clave_sede,
          soporte.nombre_es as nombre_soporte, clave_soporte,
          area_materiales.nombre_es as nombre_area_materiales,
clave_area_materia
          autor,
          titulo,
          descripcion,
          fecha_intro, fecha_modificacion

      from material, sede, soporte, area_materiales

      where (material.clave_sede = sede.clave)
          and (material.clave_soporte = soporte.clave)
          and (material.clave_area_materiales = area_materiales.clave)
          and (material.clave=1);

How can I measure SQL queries and views?

Thanks.





Re: Queries and views

From
Emmanuel SARACCO
Date:
hi,

you can use the EXPLAIN instruction.
"\h EXPLAIN" in psql for help.

bye

David Cana wrote:

> Hello!
>
> I have got a view like:
>
>     create view consulta_material as
>       select
>             material.clave as clave,
>             referencia,
>             sede.nombre_es as nombre_sede, clave_sede,
>             soporte.nombre_es as nombre_soporte, clave_soporte,
>             area_materiales.nombre_es as nombre_area_materiales,
> clave_area_materia
>             autor,
>             titulo,
>             descripcion,
>             fecha_intro, fecha_modificacion
>
>       from material, sede, soporte, area_materiales
>
>       where (material.clave_sede = sede.clave)
>             and (material.clave_soporte = soporte.clave)
>             and (material.clave_area_materiales = area_materiales.clave);
>
> I´d like to know the performance difference between...
>
>     select * from consulta_material where clave=1;
>
> And...
>
>     select
>           material.clave as clave,
>           referencia,
>           sede.nombre_es as nombre_sede, clave_sede,
>           soporte.nombre_es as nombre_soporte, clave_soporte,
>           area_materiales.nombre_es as nombre_area_materiales,
> clave_area_materia
>           autor,
>           titulo,
>           descripcion,
>           fecha_intro, fecha_modificacion
>
>       from material, sede, soporte, area_materiales
>
>       where (material.clave_sede = sede.clave)
>           and (material.clave_soporte = soporte.clave)
>           and (material.clave_area_materiales = area_materiales.clave)
>           and (material.clave=1);
>
> How can I measure SQL queries and views?
>
> Thanks.
>
>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org
>
>
>



--
Emmanuel SARACCO
Email: esaracco@noos.fr