From: Mario Jorge Nunes Filipe <mjnf@uevora.pt>
To: pgsql-admin@postgresql.org
Subject: A crashing query
Date: 28 Mar 2001 12:41:12 +0100
Message-ID: <985779672.15767.4.camel@neptuno> (raw)
Hello
Today I present myself before you with a vudu like question...
Here's the problem:
We're running several PostgreSQL databases in several different servers
(also with different PG versions :( ).
In one of our on-line systems we connect to the "local" database and a
"remote" database. The connection to the remote database was always ok,
without any kind of problems, but yesterday, out of the blue, one of the
query's (the most important one) started to crash the remote server.
The tables on the remote server are like this:
si=> \d lecciona
Table = lecciona
+----------------------------------+----------------------------------+-------+
| Field | Type |
Length|
+----------------------------------+----------------------------------+-------+
| classe | text not null default ( 'ects' ) |
var |
| curso | int4 |
4 |
| disciplina | int4 |
4 |
| ano_lectivo | int4 |
4 |
| docente | text not null |
var |
+----------------------------------+----------------------------------+-------+
Index: lecciona_mkey
There are several other tables descendand of this one. Some of them have
no extra fields, some of them do.
Yestrday a new class was added (this is the only difference from before,
and since then the following query no longer works:
select distinct disciplina from lecciona* l where l.docente='$id' and
l.ano_lectivo<= $ano_lectivo and l.classe in ('lecciona','responsável')
and not exists (select 1 from lecciona* l1 where
l1.disciplina=l.disciplina and l1.docente <> l.docente and
l1.ano_lectivo <= $ano_lectivo and l1.ano_lectivo > l.ano_lectivo and
l.classe = l1.classe ) order by disciplina";
(this query comes from a PHP script so the $... are replaced on run-time
by actual values.
I've tryed to break this thing into peaces and found out that the
"offending" part is "l1.ano_lectivo > l.ano_lectivo"
BTW: to clarify this whole thing. The tables represent the way in wich
teacher (docente) teach some subjects (disciplina). Everytime there is a
change (a new teacher starts teaching that subject, or something
similar) there is a new record saying to what schhol year it refers
(ano_lectivo). If there is a record say in 1999 of a teacher teaching
some subject and there are no other records that means that if we look
at the data in 2010 it is still valid. There are different kinds of
assignment (responsible, efectively teaching, juri, etc). What the query
try's to do is given a teacher and school year (and other things) find
out wich are the subjects that he is teaching. The subselect serves to
discover if there is someone else teaching the subject after the record
that we found for thaht teacher (i think i'm starting to get confused
here :( ).
this system is a 6.4.2, it was vacuumed and it crashes, violently...
Does anyone have a clue of why?
Thanks.
P.S. : As always I'm available to give further explanations that could
help in solving this problem.
Thanks for you attention
--
Mario Filipe
mjnf@uevora.pt
http://neptuno.sc.uevora.pt/~mjnf
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-admin@postgresql.org
Cc: mjnf@uevora.pt
Subject: Re: A crashing query
In-Reply-To: <985779672.15767.4.camel@neptuno>
References: <985779672.15767.4.camel@neptuno>
* 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