about new join syntax performance

From: "Gyozo Papp" <pgerzson(at)freestart(dot)hu>
To: <pgsql-general(at)postgresql(dot)org>
Subject: about new join syntax performance
Date: 2001-05-12 15:15:49
Message-ID: 00a201c0daf6$6e0b05c0$524ac5d5@jaguar
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello,

we are working with v7.0.2 but to upgrade to the recent version of postgres regarding to the full join syntax most demanded by our web-application.
I'd like to get some tips about how to rewrite our queries to achieve better performance.

[ from the manual 2.1.1.2. Subqueries in FROM clause ]
" More interesting cases, which can't be reduced to a plain join, arise when the subquery involves grouping or aggregation."

Take a look at this query:
SELECT * FROM (SELECT did, count(*) FROM values WHERE ... GROUP BY did HAVING count(*) > ...) AS V(did, ok) JOIN document AS D USING(did);

My question is this significantly faster than two separate queries which are used now (in v7.0.2) via PHP (libpq):
SELECT did, count(*) INTO TEMPORARY TABLE tmp FROM values WHERE ... GROUP BY did HAVING count(*) > ...;
SELECT * FROM tmp AS V, document AS D WHER V.did = D.did;

additional informations:
table document:
did serial primary key,
content text not null
total rows = 22.000 -

table values :
did serial references (document),
value text not null,
/* other columns */
total rows = 2 or 5 times of document rows, (there are 2 up to 5 references to each document)

I'd like to know whether it's worth changing the scripts to use the new join syntax.

Papp Gyozo
- pgerzson(at)freestart(dot)hu

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David Stevenson 2001-05-12 16:00:35 Question on Starting Postgres for the first time
Previous Message will trillich 2001-05-12 14:32:51 Re: simple rule question