Re: Not so simple query and a half million loop

From: DANIEL CRISTIAN CRUZ <daniel(dot)cruz(at)sc(dot)senai(dot)br>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Daniel Cristian Cruz <danielcristian(at)gmail(dot)com>
Cc: pgsql-admin <pgsql-admin(at)postgresql(dot)org>
Subject: Re: Not so simple query and a half million loop
Date: 2008-12-02 16:36:51
Message-ID: b1955054813e88a132ce7a1edba1bc79@intranet.sc.senai.br
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-performance

Because of a Bad Model...

When it is a single event egw_cal_dates always has a record with cal_start =
0.

When it is a recurrent event, egw_cal_dates has a record with cal_start = 0
and a record with cal_start equal to recurrent start.

With this construction it returns correctly calendar exceptions...

It's somewhat complex but it returns slowly ok.

Regards,

"Alvaro Herrera" <alvherre(at)commandprompt(dot)com> escreveu:
> Daniel Cristian Cruz escribió:
>> No one knows why I got "actual time=0.014..0.570 rows=30 loops=511222"
>> and "actual time=0.005..0.006 rows=1 loops=15158976"?
>>
>> With:
>> cu.cal_user_type = 'u' AND
>> cu.cal_recur_date = COALESCE((SELECT cd.cal_start FROM egw_cal_dates
>> icd WHERE icd.cal_id = cd.cal_id AND icd.cal_start = cd.cal_start AND
>> icd.cal_start <> 0), 0)
>> ~ 450 seconds
>
> I don't know, but why are you using such an expression instead of an
> outer join?
>
> --
> Alvaro Herrera
http://www.CommandPrompt.com/
> PostgreSQL Replication, Consulting, Custom Development, 24x7 support
>
> --
> Sent via pgsql-admin mailing list (pgsql-admin(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-admin
>

--
<span style="color: #000080">Daniel Cristian Cruz
</span>Administrador de Banco de Dados
Direção Regional - Núcleo de Tecnologia da Informação
SENAI - SC
Telefone: 48-3239-1422 (ramal 1422)

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Chris Browne 2008-12-02 17:12:00 Re: change user passwd
Previous Message Alvaro Herrera 2008-12-02 16:07:37 Re: Not so simple query and a half million loop

Browse pgsql-performance by date

  From Date Subject
Next Message Scott Carey 2008-12-02 17:50:03 Re: analyzing intermediate query
Previous Message Alvaro Herrera 2008-12-02 16:07:37 Re: Not so simple query and a half million loop