Fernando Nasser <fnasser@redhat.com> writes:
> So the psql program reads data and spits it out (to /dev/null, which is fast)
> every row it reads.
> The JDBC driver has to store all these rows in memory and wait for you
> to tell it what you want to do with it.
But libpq also stores the entire query result in memory. That doesn't
seem like a reason for JDBC to be slower.
One thing I'd wonder about is the overall startup overhead for Java.
What's the relative time to do a trivial "select 2+2" each way?
regards, tom lane