Skip site navigation (1) Skip section navigation (2)

Re: [BUGS] SQL optimisation dead loop

From: Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us>
To: patrick(at)dante(dot)urbanet(dot)ch (Valsecchi Patrick)
Cc: pgsql-bugs(at)postgreSQL(dot)org
Subject: Re: [BUGS] SQL optimisation dead loop
Date: 1999-03-14 18:19:27
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-bugs
Version 6.5, due to go beta soon, will fix this problem.  I have
overhauled the optimizer.

> Your name               : Patrick Valsecchi 
> Your email address      : patrick(at)dante(dot)urbanet(dot)ch
> System Configuration
> ---------------------
>   Architecture (example: Intel Pentium)         : Pentium or K6 ???
>   Operating System (example: Linux 2.0.26 ELF)  : Linux 2.0.32 RedHat5.0
>   PostgreSQL version (example: PostgreSQL-6.3.2)  : PostgreSQL-6.3.2
>   Compiler used (example:  gcc 2.7.2)           : gcc version
> Please enter a FULL description of your problem:
> ------------------------------------------------
> I am developing a big (15 tables) web application witch use Postgres.
> One of my queries is crashing badly postgres. It's consuming all the memory and die when it's full.
> It seems to be the optimizer, since postgres is dieing even if I add an EXPLAIN before the query.
> I have put in my tables the only data for having only one row as result of my query.
> Please describe a way to repeat the problem.   Please try to provide a
> concise reproducible example, if at all possible: 
> ----------------------------------------------------------------------
> Here is the building commands:
> CREATE TABLE client (nom varchar not null, passwd varchar not null,
>   peut_creer bool not null, peut_lire bool not null, peut_stat bool not null,
>   est_admin bool, est_fournisseur bool not null, est_client bool not null,
>   raison_social varchar, contact varchar, adresse varchar, telephone varchar,
>   fax varchar, adr_facture varchar);
> CREATE TABLE type (nom varchar not null, descr varchar not null);
> CREATE TABLE offre (client oid, a_lut oid, tipe oid, dest5 oid, zone5 oid, date_creation datetime, valide_depuis datetime, valide_jusqua datetime,
>   fichier oid, commission float);
> CREATE TABLE a_lut (offre oid, client oid, date_lecture datetime);
> CREATE TABLE prix (offre oid, valeur float, nb_jours int, valide_de datetime,
>   valide_a datetime);
> CREATE TABLE zone5 (nom varchar, zone4 oid);
> CREATE TABLE zone4 (nom varchar, zone3 oid);
> CREATE TABLE zone3 (nom varchar, zone2 oid);
> CREATE TABLE zone2 (nom varchar, zone1 oid);
> CREATE TABLE zone1 (nom varchar);
> CREATE TABLE dest5 (nom varchar, dest4 oid);
> CREATE TABLE dest4 (nom varchar, dest3 oid);
> CREATE TABLE dest3 (nom varchar, dest2 oid);
> CREATE TABLE dest2 (nom varchar, dest1 oid);
> CREATE TABLE dest1 (nom varchar);
> And here is the "query of death":
> SELECT offre.oid,offre.date_creation,offre.valide_depuis,offre.valide_jusqua,
>   offre.commission,offre.fichier,offre.client,type.oid,type.nom,type.descr,
>   dest5.oid,dest5.nom,dest4.oid,dest4.nom,dest3.oid,dest3.nom,dest2.oid,
>   dest2.nom,dest1.oid,dest1.nom,zone5.oid,zone5.nom,zone4.oid,zone4.nom,
>   zone3.oid,zone3.nom,zone2.oid,zone2.nom,zone1.oid,zone1.nom FROM
>     offre,type,dest5,dest4,dest3,dest2,dest1,zone5,zone4,zone3,zone2,zone1 WHERE
>   offre.tipe=type.oid AND offre.dest5=dest5.oid AND dest5.dest4=dest4.oid AND
>   dest4.dest3=dest3.oid AND dest3.dest2=dest2.oid AND dest2.dest1=dest1.oid AND
>   offre.zone5=zone5.oid AND zone5.zone4=zone4.oid AND zone4.zone3=zone3.oid AND
>   zone3.zone2=zone2.oid AND zone2.zone1=zone1.oid
> I know, it's a huge query, but it's under the 8192 bytes limit.
> If you know how this problem might be fixed, list the solution below:
> ---------------------------------------------------------------------
> =============
> Thanks for your help.
> I'm not subscribed to the mailing list. Send your questions directly to me...
> Best regards.

  Bruce Momjian                        |
  maillist(at)candle(dot)pha(dot)pa(dot)us            |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

pgsql-bugs by date

Next:From: Unprivileged userDate: 1999-03-15 04:47:33
Subject: General Bug Report: Transaction END statemente generates NOTICE: EndTransactionBlock and not inprogress/abort state
Previous:From: Unprivileged userDate: 1999-03-12 11:08:07
Subject: General Bug Report: Handling of quoted identifiers and sequences

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group