I did some profiling related to printtup() by a simple libpq "SELECT *
test" program (revised from the libpq programing sample in document
without retriving the results). There are 260k or so records in table
test(i int).
/* original version - prepare tuple and send */
SELECT * TIMING: 0.63 sec
/* Prepare but not sendIn printtup():- pq_endmessage(&buf);+ pfree(buf.data);+ buf.data = NULL;*/
SELECT * TIMING: 0.46 sec
/* No prepare no sendIn ExecSelect():- (*dest->receiveSlot) (slot, dest);
*/
SELECT * TIMING: 0.08 sec
So we spend a portion of time at preparing tuples in printtup() by
converting the tuple format to a network format. I am not quite familiar
with that part, so I wonder is it possible to try to send with original
tuple format with minimal preparing job (say handling toast) -- which
might increase the amount of data of network communication, but may reduce
the CPU on server side?
If this is not a non-starter, I am happy to look into details,
Regards,
Qingqing