- Slow Query - Mailing list pgsql-performance

From Rui Carvalho
Subject - Slow Query
Date
Msg-id 4cb7e1b20907010240qd604c12v965a3b8927130041@mail.gmail.com
Whole thread Raw
Responses Re: - Slow Query  (Mike Ivanov <mikei@activestate.com>)
Re: - Slow Query  (justin <justin@emproshunts.com>)
List 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

pgsql-performance by date:

Previous
From: Mike Ivanov
Date:
Subject: Re: random slow query
Next
From: Mike Ivanov
Date:
Subject: Re: - Slow Query