Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id AE4BB476480 for ; Thu, 6 Jun 2002 06:48:07 -0400 (EDT) Received: from cerbero.opla.it (host189-174.pool21757.interbusiness.it [217.57.174.189]) by postgresql.org (Postfix) with ESMTP id 0DADB476465 for ; Thu, 6 Jun 2002 06:48:05 -0400 (EDT) Received: from oplantserver (oplantserver [192.168.1.200]) by cerbero.opla.it (8.11.6/8.11.6) with SMTP id g56AYjD28327 for ; Thu, 6 Jun 2002 12:34:46 +0200 Message-ID: <0f6e01c20d47$9604eee0$c801a8c0@opla.it> From: "Giorgio Ponza" To: References: Subject: Re: [ADMIN] performance issue using DBI Date: Thu, 6 Jun 2002 12:47:39 +0200 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0F6B_01C20D58.59508ED0" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Archive-Number: 200206/199 X-Sequence-Number: 25351 This is a multi-part message in MIME format. ------=_NextPart_000_0F6B_01C20D58.59508ED0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable i'm not a db expert but i think that a transaction with more than 20.000 op= erations cant be quick anyway. I think you have to work in other ways, maybe reading one line at a time, d= oing the operations, committing, deleting the line from the file. to remember all this transactions i think postgres must swap more then a 38= 6 with 4MB Ram! Bye Giorgio ----- Original Message -----=20 From: Nicolas Nolst=20 To: pgsql-admin@postgresql.org ; pgsql-general@postgresql.org=20 Sent: Thursday, June 06, 2002 11:40 AM Subject: [ADMIN] performance issue using DBI Hi all, I have developped a perl script to populate a database with two tables: s= essions and actions. the table actions contains the following columns: session_id, url, timest= amp. The column session_id references to the table sessions. the table sessions contains the following columns: session_id, remote_ip, phone_type, phone_number. The column session_id is serial. The lines of the table actions which are part of the same session have th= e same session_id. There are then more lines in the table actions than in the table session. To fill the two tables, I first need to know if the session already exist= s for a certain phone_type, a certain remote_ip and a certain phone_number: SELECT session_id FROM sessions WHERE (phone_number =3D ?) AND (remote_ip= =3D ?) AND (phone_type =3D ?) ORDER BY session_id; I also need to apply a criteria to know if I have to add a new entry in t= he table sessions or not: SELECT (max(timestamp) + ?)
i'm not a db expert but i think that a tra= nsaction=20 with more than 20.000 operations cant be quick anyway.
I think you have to work in other way= s, maybe=20 reading one line at a time, doing the operations, committing, deleting the = line=20 from the file.
to remember all this transactions i think = postgres=20 must swap more then a 386 with 4MB Ram!
Bye
Giorgio
----- Original Message -----
Fro= m:=20 Nicolas = Nolst=20
To: pgsql-admin@postgresql.org= ; pgsql-general@postgresql.org= =20
Sent: Thursday, June 06, 2002 11:4= 0=20 AM
Subject: [ADMIN] performance issue= using=20 DBI

Hi all,

I have developped a perl script to populate a= =20 database with two tables: sessions
and actions.

the table actio= ns=20 contains the following columns: session_id, url, timestamp.
The column= =20 session_id references to the table sessions.

the table sessions=20 contains the following columns: session_id, remote_ip,
phone_type,=20 phone_number. The column session_id is serial.

The lines of the ta= ble=20 actions which are part of the same session have the=20 same
session_id.

There are then more lines in the table actions= than=20 in the table session.


To fill the two tables, I first need to = know=20 if the session already exists for a
certain phone_type, a certain remo= te_ip=20 and a certain phone_number:

SELECT session_id FROM=20 sessions WHERE (phone_number =3D ?) AND (remote_ip  =3D ?)=
AND=20 (phone_type =3D ?) ORDER BY session_id;

I also need to a= pply a=20 criteria to know if I have to add a new entry in the
table= =20 sessions or not:

SELECT (max(timestamp) + ?)<? FROM= =20 actions WHERE (session_id =3D ?);



If the session alre= ady=20 exists I add a line in the table actions with a INSERT

If the sess= ion=20 doesn't exist or if the criteria is true, I add a line in the
table=20 sessions with an INSERT and then add  a line with a INSERT in the ta= ble=20 actions (I use nextval and currval).

I have put indexes on=20 sessions(session_id), sessions(msisdn),
actions(session_id) and=20 actions(timestamp). I process one log file of about 20000 lines every day= . All=20 the lines are processed in one transaction (autocommit set to 0).

= My=20 problem is that populating my database is slower  when the data gets= =20 bigger
and the performance falls dramatically. I thought that is would= be=20 improve with
my indexes but the problem still persists.

Could y= ou=20 please give me some clues that could solve this=20 issue.

Thanks.



Nicolas Nolst=20
=20


MSN Photos is the easiest way to share and print your photos: Click=20 Here
------=_NextPart_000_0F6B_01C20D58.59508ED0--