Slow insert performance using postgreSQL and PEAR
| From: | K.G. Subramanian | Date: | Wed, 04 Jun 2003 18:41:36 +0000 |
| Subject: | Slow insert performance using postgreSQL and PEAR | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-5797@lists.php.net to get a copy of this message | ||
Hi All,
We did a simple benchmark on PEAR DB 1.4 and Postgresql 7.x running
under Redhat Linux 8.x.
To do the benchmark, we wrote a simple php script which would be called
by the browser. This script does a X number inserts into a table. What
we noticed was the following;
1. When the fsync option is on(i.e. postmaster is started without
the -F option), for 50,000 inserts it took about 5 hours.
2. With fsync turned off in postgresql, the time came down to
approximately 90 seconds. In both these cases, autocommit was on
3. With one single long running transaction, the time came down to
61 seconds.
4. Without using PEAR, using postgresql functions such as
pg_connect, the time came down to 30 seconds.
Now our question is,
1. Why is such a large difference between 3 and 4.
2. Is PEAR adding so much overhead or is it something that we doing
wrong. When you look at the pear DB code, it's calling the same
postgresql functions!!. Is there a way to optimize this situation?
3. There are different ways of connecting to postgresql, such as unix
domain sockets and TCP/IP sockets. Is it possible that pg_connect is
using a different mechanism as compared to the call being made through
PEAR DB?
BTW, we are using large number of insert statements to optimize our
postgresql installation. In our real application, this effect would be
achieved by multiple simultaneous clients connecting to PHP/postgres
instance.
Regards
kg