Craig James <craig_james@xxxxxxxxxxxxxx> writes: > Valentin Bogdanov wrote: >> I have ran quite a few tests comparing how long a query takes to >> execute from Perl/DBI as compared to psql/pqlib. No matter how many >> times I run the test the results were always the same. >> >> I run a SELECT all on a fairly big table and enabled the >> log_min_duration_statement option. With psql postgres consistently >> logs half a second while the exact same query executed with Perl/DBI >> takes again consistently 2 seconds. > The problem may be that your two tests are not equivalent. When Perl > executes a statement, it copies the *entire* result set back to the > client before it returns the first row. Sure, but so does psql (unless you've turned on the magic FETCH_COUNT setting). I think the theories about prepared versus literal statements were more promising; but I don't know DBI well enough to know exactly what it was sending to the server. regards, tom lane