Re: Query optimization - Mailing list pgsql-general

From David G Johnston
Subject Re: Query optimization
Date
Msg-id 1414547659900-5824746.post@n5.nabble.com
Whole thread Raw
In response to Query optimization  (Jorge Arevalo <jorgearevalo@libregis.org>)
Responses Re: Query optimization
List pgsql-general
Jorge Arévalo-2 wrote
> (SELECT value1,value2,value3,value4,value5, hstore(ARRAY['field9',
> 'field10', 'field11', 'field12', 'field13', 'field14'], ARRAY[field9,
> field10, field11, field12, field13, field14) as metadata, value7, (select
> array((select row(f1, f2) from table2 p where p.field7 = field7))) as
> values_array FROM table1)

You might try seeing whether:

FROM table1 JOIN (
SELECT field7, array_agg(row(f1, f2)) AS values_array FROM table2 GROUP BY
field7
) tbl2_agg USING (field7)

helps...

I'm also dubious (though this isn't necessarily a performance issue) of:

array[...] AS metadata

Without context I would say this would be better as a composite type instead
of an array.  You may find it useful to use named composite types elsewhere
too...

David J.




--
View this message in context: http://postgresql.1045698.n5.nabble.com/Query-optimization-tp5824739p5824746.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.


pgsql-general by date:

Previous
From: David G Johnston
Date:
Subject: Re: Query optimization
Next
From: Michael Paquier
Date:
Subject: Re: [BUGS] Need guidance on regression.diffs