From nnolst@hotmail.com Mon Jun 3 16:57:05 2002 Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id 20C4B475969; Mon, 3 Jun 2002 12:57:05 -0400 (EDT) Received: from hotmail.com (f141.law4.hotmail.com [216.33.149.141]) by postgresql.org (Postfix) with ESMTP id 78FA747592F; Mon, 3 Jun 2002 12:57:00 -0400 (EDT) Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Mon, 3 Jun 2002 09:57:00 -0700 Received: from 195.95.20.44 by lw4fd.law4.hotmail.msn.com with HTTP; Mon, 03 Jun 2002 16:56:59 GMT X-Originating-IP: [195.95.20.44] From: "Nicolas Nolst" To: pgsql-admin@postgresql.org, pgsql-general@postgresql.org Subject: performance issues with DBI module when data too big Date: Mon, 03 Jun 2002 16:56:59 +0000 Mime-Version: 1.0 Content-Type: text/html Message-ID: X-OriginalArrivalTime: 03 Jun 2002 16:57:00.0216 (UTC) FILETIME=[AD7A4B80:01C20B1F] X-Archive-Number: 200206/7 X-Sequence-Number: 4442

Hi all,

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

the table actions contains the following columns: session_id, url, timestamp. 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 the 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 exists for a certain phone_type, a certain remote_ip and a certain phone_number:

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

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

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

 

If the session already exists I add a line in the table actions with a INSERT

If the session doesn't exist or if the criteria is true, I add a line in the table sessions with an INSERT, retrieve the session_id of the line just added with the following request

SELECT session_id FROM sessions where (msisdn=?) AND (remote_ip=?) AND (user_agent=?) ORDER BY session_id DESC LIMIT 1

and the add with a INSERT a line in the table actions.

I have put indexes on sessions(session_id), sessions(msisdn), actions(session_id).

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

Could you please give me some clues that could solve this issue.

Thanks.


 

Nicolas Nolst



Join the world’s largest e-mail service with MSN Hotmail. Click Here
From janwieck@yahoo.com Mon Jun 3 18:03:59 2002 Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id D8D8B475A17 for ; Mon, 3 Jun 2002 14:03:59 -0400 (EDT) Received: from smtp016.mail.yahoo.com (smtp016.mail.yahoo.com [216.136.174.113]) by postgresql.org (Postfix) with SMTP id C15B0475A0E for ; Mon, 3 Jun 2002 14:03:58 -0400 (EDT) Received: from unknown (HELO saturn.janwieck.net) (janwieck@192.233.92.205 with login) by smtp.mail.vip.sc5.yahoo.com with SMTP; 3 Jun 2002 18:03:58 -0000 Received: (from wieck@localhost) by saturn.janwieck.net (8.11.2/8.11.2) id g53HoH203184; Mon, 3 Jun 2002 13:50:17 -0400 From: Jan Wieck Message-Id: <200206031750.g53HoH203184@saturn.janwieck.net> Subject: Re: [GENERAL] performance issues with DBI module when data too big In-Reply-To: from Nicolas Nolst at "Jun 3, 2002 04:56:59 pm" To: Nicolas Nolst Date: Mon, 3 Jun 2002 13:50:17 -0400 (EDT) Cc: pgsql-admin@postgresql.org, pgsql-general@postgresql.org X-Mailer: ELM [version 2.4ME+ PL68 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Archive-Number: 200206/18 X-Sequence-Number: 4453 Nicolas Nolst wrote: [text/html is unsupported, treating like TEXT/PLAIN] > [...] >

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

>

Could you please give me some clues that could solve this issue.

Is your database frequently vacuumed and analyzed (and do you frequently read frequently asked questions)? >

Thanks.

>


 

Nicolas Nolst

And just for the record, do you prefer answers to HTML mail in Postscript, PDF, DVI or nothing at all? Jan -- #======================================================================# # It's easier to get forgiveness for being wrong than for being right. # # Let's break this rule - forgive me. # #================================================== JanWieck@Yahoo.com # From clists@perrin.socsci.unc.edu Mon Jun 3 18:21:53 2002 Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id 775AA475A0E; Mon, 3 Jun 2002 14:21:53 -0400 (EDT) Received: from smtp.unc.edu (smtpsrv10.isis.unc.edu [152.2.1.241]) by postgresql.org (Postfix) with ESMTP id D26D847595D; Mon, 3 Jun 2002 14:21:46 -0400 (EDT) Received: from perrin.socsci.unc.edu (mail@perrin.socsci.unc.edu [152.2.242.190]) by smtp.unc.edu (8.12.2/8.12.2) with ESMTP id g53IL89X013927; Mon, 3 Jun 2002 14:21:08 -0400 (EDT) Received: from clists (helo=localhost) by perrin.socsci.unc.edu with local-esmtp (Exim 3.35 #1 (Debian)) id 17EwS5-0005FB-00; Mon, 03 Jun 2002 14:21:09 -0400 Date: Mon, 3 Jun 2002 14:21:08 -0400 (EDT) From: Andrew Perrin To: Nicolas Nolst Cc: pgsql-admin@postgresql.org, pgsql-general@postgresql.org Subject: Re: performance issues with DBI module when data too big In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=iso-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE X-Archive-Number: 200206/8 X-Sequence-Number: 4443 Are you using the {AutoCommit =3D> 0} argument to DBI->connect()? If not, do so, and then add a $dbh->commit; line when you're done with the inserts. Should help a lot. ---------------------------------------------------------------------- Andrew J Perrin - http://www.unc.edu/~aperrin Assistant Professor of Sociology, U of North Carolina, Chapel Hill clists@perrin.socsci.unc.edu * andrew_perrin (at) unc.edu On Mon, 3 Jun 2002, Nicolas Nolst wrote: >=20 > Hi all, >=20 > I have developped a perl script to populate a database with two tables: > sessions and actions. >=20 > the table actions contains the following columns: session_id, url, > timestamp. The column session_id references to the table sessions.=A0 >=20 > the table sessions contains the following columns: session_id, remote_ip, > phone_type, phone_number. The column session_id is serial. >=20 > The lines of the table actions which are part of the same session have > the same session_id. >=20 > There are then more lines in the table actions than in the table session. >=20 >=20 > To fill the two tables, I first need to know if the session already > exists for a certain phone_type, a certain remote_ip and a certain > phone_number: >=20 > SELECT=A0session_id=A0FROM sessions=A0WHERE (phone_number =3D ?)=A0AND (r= emote_ip=A0 > =3D ?)=A0AND (phone_type =3D ?)=A0ORDER BY=A0session_id; >=20 > I also need to apply a criteria to=A0know if I have to=A0add a new entry = in > the table sessions or not: >=20 > SELECT=A0(max(timestamp) + ?)=20 > =A0 >=20 > If the session already exists I add a line in the table actions with a > INSERT >=20 > If the session doesn't exist or if the criteria is true, I add a line in > the table sessions with an INSERT, retrieve the session_id of the line > just added with the following request >=20 > SELECT=A0session_id=A0FROM sessions where (msisdn=3D?)=A0AND (remote_ip= =3D?)=A0AND > (user_agent=3D?)=A0ORDER=A0BY session_id=A0DESC=A0LIMIT 1 >=20 > and the add with a INSERT a line in the table actions. >=20 > I have put indexes on sessions(session_id), sessions(msisdn), > actions(session_id). >=20 > My problem is that populating my database is slower=A0 when the data gets > bigger and the performance falls dramatically. I thought that is would be > improve with my indexes but the problem still persists. >=20 > Could you please give me some clues that could solve this issue. >=20 > Thanks. >=20 >=20 > =A0 >=20 > Nicolas Nolst >=20 > [belgium_gs.gif] >=20 > _________________________________________________________________________= _______ > Join the world=92s largest e-mail service with MSN Hotmail. Click Here >=20 >=20