Re: Query optimisation - Mailing list pgsql-general

From Naz Gassiep
Subject Re: Query optimisation
Date
Msg-id 47F9B4C1.9070602@mira.net
Whole thread Raw
In response to Re: Query optimisation  (Craig Ringer <craig@postnewspapers.com.au>)
Responses Re: Query optimisation  (Craig Ringer <craig@postnewspapers.com.au>)
List pgsql-general
As you can see, they all are the same table, just repeatedly joined
with aliases. The images table has several fields, each one referring
to a different sized version of the image. It then has to join against
the files table for each size to get the file that corresponds with
that image version.
- Naz.


Craig Ringer wrote:
<blockquote cite="mid:47F9A67A.9090903@postnewspapers.com.au"
 type="cite">
  Naz Gassiep wrote:



                    JOIN files imageid_file ON (images.imageid =
imageid_file.fileid)
                JOIN files size120_file ON (images.size120 =
size120_file.fileid)
                JOIN files size240_file ON (images.size240 =
size240_file.fileid)
                JOIN files size420_file ON (images.size420 =
size420_file.fileid)
                JOIN files size600_file ON (images.size600 =
size600_file.fileid)
                JOIN files size800_file ON (images.size800 =
size800_file.fileid)
                JOIN files size1024_file ON (images.size1024 =
size1024_file.fileid)
                JOIN files size130sq_file ON (images.size130sq =
size130sq_file.fileid)
                JOIN files size240sq_file ON (images.size240sq =
size240sq_file.fileid)
                JOIN files size420sq_file ON (images.size420sq =
size420sq_file.fileid)
                JOIN images_sites ON (images_sites.imageid =
images.imageid)



That's a whole lot of joins.

Do all those tables have the same fields? Can you unify them into one
table with an additional field like "imagesize" and use an appropriate
WHERE clause when looking up the table?

--
Craig Ringer

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Query optimisation
Next
From: Alban Hertroys
Date:
Subject: Re: select distinct and index usage