From: | Rui Carvalho <rui(dot)hmcarvalho(at)gmail(dot)com> |
---|---|
To: | "pgsql-performance(at)postgresql(dot)org" <pgsql-performance(at)postgresql(dot)org> |
Subject: | - Slow Query |
Date: | 2009-07-01 09:40:02 |
Message-ID: | 4cb7e1b20907010240qd604c12v965a3b8927130041@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
HI Gurus ,
i have this query (i think is a simple one)
it takes me 1,7s to run it, it's not to long, but considering it takes 1,7s
to return 71lines makes me wonder... is there anyother way to do this, on a
first look??
any sugestion would be largely appreciated.
SELECT distinct on (bien.uid) bien.uid , bien.date_creation ,
bien.date_modification , bien.nom , bien.numero_voie , bien.mer ,
bien.proximite , bien.nom_voie , bien.type_voie , bien.lieudit ,
bien.arrondissement , bien.montagne , bien.complement_adresse , bien.xy_geo
, bien.ref_type_avancement , bien.ref_agence , bien.acces_handicape ,
bien.surface_totale , bien.ref_type_transaction , bien.reference_bien ,
bien.ref_type_bien , bien.bien_exception ,
bien.video_online , bien.geom , habitation.nombre_de_chambres,
habitation.nombre_de_wc ,
prix.montant , ville.nom ,ville.abreviation ,
ville.code_insee , ville.code_postal ,
freguesia_ville.code_insee , freguesia_ville.code_postal
, freguesia_ville.ref_freguesia , freguesia_ville.ref_ville ,
freguesia.nom , freguesia.numero , departement.nom ,
departement.numero , region.nom ,region.numero , zone.zone_public ,
type_transaction.nom, mandat.numero_mandat_pt
FROM bien
LEFT outer JOIN prix ON prix.ref_bien = bien.uid AND prix.ref_type_prix in
(2,9) and prix.montant !=0 LEFT outer JOIN habitation on habitation.uid =
bien.uid
LEFT outer JOIN ville ON ville.uid = bien.ref_ville LEFT outer JOIN
freguesia_ville ON freguesia_ville.ref_ville =ville.uid
LEFT outer JOIN freguesia ON freguesia.uid = freguesia_ville.ref_freguesia
LEFT outer JOIN departement ON departement.uid =ville.ref_departement LEFT
outer JOIN region ON region.uid = departement.ref_region
LEFT outer JOIN zone ON zone.ref_bien = bien.uid JOIN imagebien ON
imagebien.ref_bien = bien.uid left outer join mandat on
mandat.ref_bien=bien.uid
LEFT outer JOIN type_transaction ON type_transaction.uid =
bien.ref_type_transaction
LEFT OUTER JOIN agence on agence.uid = bien.ref_agence
WHERE imagebien.uid IS NOT NULL AND bien.statut = 0 and
bien.visible_internet = 1 and bien.ref_agence = XXXXXXX
thanks.
RC
From | Date | Subject | |
---|---|---|---|
Next Message | Mike Ivanov | 2009-07-01 16:39:05 | Re: - Slow Query |
Previous Message | Mike Ivanov | 2009-07-01 00:58:46 | Re: random slow query |