From: Imtiaz. S. M <imtiaz_sm@yahoo.com>
To: pgsql-sql@postgresql.org
Subject: pqReadData() error
Date: Mon, 06 Dec 1999 13:14:51 +0530
Message-ID: <384B6971.2A893599@yahoo.com> (raw)
Check this out.
I have a table with the following structure.
ip_ad char(20)
type int2
bytes int8
dates datetime
Newest data keeps getting filled every hour into the table and the
oldest one hour data gets deleted. So you have the network traffic data
for the last one day in this table which consists of 12 one hour summary
blocks. Now to delete the oldest data I use the following SQL queries.
create table tempdates as select distinct dates from daydata;
delete from daydata where dates in (select b.dates from tempdates a,
tempdates b where a.dates-b.dates > '22 hours');
So this deletes data from the table where the data is more than 1 day
old.
This works fine if the no. of rows are very small. But in my case
approximately 500 new rows get inserted and 500 oldest rows get deleted
every one hour. The query takes a long time and then gives me the
following error
"pqReadData() -- backend closed the channel unexpectedly.
This probably means the backend terminated
abnormally before or while processing the request.
We have lost the connection to the backend, so further processing is
impossible. Terminating."
But it works efficiently if I give the following queries instead of the
above one. All I do is replace the "in" with "="
create table tempdates as select distinct dates from daydata;
delete from daydata where dates =(select b.dates from tempdates a,
tempdates b where a.dates-b.dates > '22 hours');
But unfortunaltely for me I cannot use the above query because sometimes
multiple rows might be retrurned from the subquery ie when some data is
lost in between.
Also if I substitute the subquery with actual values for dates , the
query works really fast without giving any errors.
I have tried all possible combinations of indexing also. Still I get the
same error.
Is ther any other way to work around it.
I am using Postgres version 6.5.1 on Linux 2.0.36 Kernel ,Redhat 5.2 ,
Pentium PII 350 Mhz
I have 32MB of Ram.
Thanx in advance
regards
Imtiaz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: imtiaz_sm@yahoo.com
Subject: Re: pqReadData() error
In-Reply-To: <384B6971.2A893599@yahoo.com>
References: <384B6971.2A893599@yahoo.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox