From: | "Michael Guyver" <kenevel(at)googlemail(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Concatenate performance question |
Date: | 2006-11-29 12:14:30 |
Message-ID: | 30b57570611290414i53b5205fs6c8457f90f597249@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi there,
I've got a rather large PL/pgSQL function which returns a varchar
(though it could be text, char or blob, I'm not fussy) containing JSON
information (where JSON is Javascript Object Notation). The middle
tier of the app does pretty much sweet FA except pass this straight
back to the client. I'm interested in seeing how much faster I can get
the app to process a request this way as opposed to retrieving the
data over three or four calls to the DB before constructing the JSON
response in the middle tier.
I've got to the point where I suspect the concatenation could do with
some attention. What is the fastest way of returning this to the
client?
I thought that storing the individual segments of text in an array and
stitiching it all together at the end of the function may be a fast
way of doing things, using an
array_to_string(resultArray,'');
call. However I have my doubts whether the
resultArray := array_append(resultArray,'next token');
is performant as it looks as though it's constructing a new array from
the argument each time its called. Can someone confirm or rebut this?
How would a simple
result := result || 'next token';
perform? The result size is in the 20-25 Kb range.
A mate mentioned that the way Oracle's OWS does it is to stream the
response back as a blob. I presume he means that the function could
iterate over the different queries' result-sets and simply write the
results to the blob before returning. Can anyone shed any light on
this approach and its applicabilty to PostgreSQL?
Cheers
Michael
From | Date | Subject | |
---|---|---|---|
Next Message | Marc Evans | 2006-11-29 12:25:48 | Looking for pgsql sysadmin |
Previous Message | Terry Yapt | 2006-11-29 11:49:08 | Re: [Windows] Pg_Restore on 8.1.5 and so on... |