Jorge Arévalo-2 wrote > So, I first generate a common table records_to_insert, using data from > table1 and table2, and then call a function fill_table3_function, in order > to insert the values into table3 (I do more things apart from insert, > that's reason to call a function instead of just raising an insert query). > There are indexes created on all the columns that need them. I would suggest you figure out how to do what you need without pushing the insert into the function. > So, is there anything obviously wrong with my query? Any changes to make > it > faster? You shouldn't expect much useful help when the important part of your query is not provided. Creating arrays and hstores is expensive but whether that is the biggest factor is impossible to tell. David J. -- View this message in context: http://postgresql.1045698.n5.nabble.com/Query-optimization-tp5824739p5824744.html Sent from the PostgreSQL - general mailing list archive at Nabble.com. -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general