X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 937F4D1B4AD for ; Thu, 22 Jan 2004 15:30:16 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 94732-02 for ; Thu, 22 Jan 2004 11:29:49 -0400 (AST) Received: from kserver17.erfurt12.de (unknown [80.190.233.41]) by svr1.postgresql.org (Postfix) with ESMTP id E277DD1E926 for ; Thu, 22 Jan 2004 11:29:38 -0400 (AST) Received: by kserver17.erfurt12.de (Postfix, from userid 642) id 7FA355A816F; Thu, 22 Jan 2004 16:13:23 +0100 (CET) To: pgsql-performance@postgresql.org From: postgres@countup.de Subject: Function & Update/Insert Problem and Performance Content-Type: text/html; charset=iso-8859-1; Message-Id: <20040122151323.7FA355A816F@kserver17.erfurt12.de> Date: Thu, 22 Jan 2004 16:13:23 +0100 (CET) X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200401/216 X-Sequence-Number: 5390 Hi there,

i m new in this board. I read a little here to find a solution for my problem. But i couldn´t find something.

My Problem ist:
I m programming a counter in PHP with Postgres as DB. I had 6,000 visitors across all day, so everything worked fine first.
Yesterday i got 80K Users at my sites, that was the point were all crashed.

I have an Intel Celeron 2,2 Server with 1 GB Ram
I have PHP in Version 4.2.0 and Postgres 7.3.4
The Connection to DB from php ist over PEAR-DB-Class

I wrote a postgres function which gets up to 17 parameters such as os, browser, referer and so on
This function tries to update a row in the db/table which matches with the hour of the current datetime
If this returns not found then i do an insert
So i have a few tables and th e update-insert procedure is done a few times (about 15-17 times). At the end i collect some data and return them to show as the counter-banner

I called the function with expain analyze, so it showed something around 222 ms duration

My first problem ist, what is about transactions? Do i have to care about? I read that a function is always just one transaction
So if something fails, the whole function will be undone with a rollback

Second problem is my update works just if they are not too much visitors/postmaster processes...
If there are too much postmasters i get too many errors in my data (the update seems not to work, it doesnt find the exisiting row in the current hour, so it does inserts i think)
Do i have to care about permissions? I have set for example “lock table os in exclusive mode” for all tables i work with

The next problem is, i m looking to get 2,000,000 visitors day
So i will have to change something in pos tgres config right? But what exactly? Max_connectionsnumber, what is else important? Something in apache maybe too?

I hope i can get some ideas, because everything works, except the perfomance and the number of the visitors manipulate data in wrong way and are making me seek!
I know there are too many questions, but every idea of you guys will help me, thanks

Thank you so far

Boris