Subject Re: [firebird-support] Question about better performance Query
Author Nick Upson
try:

select first 1 a.pfad

from t_pictures a where status <> 6 and

not exists (select 1 from t_pictures where status < 5 and kd_id = a.kd_id
and
li_id = a.li_id)

into :pfad;


(also first 1 will return just 1 record but it could be any record in the
set as you have no "order by")

Nick Upson



On 21 March 2012 15:07, Olaf Kluge <olaf.kluge@...> wrote:

> **
>
>
> Hello,
>
> at this time I have create an statement:
>
> select first 1 a.pfad
>
> from t_pictures a where status <> 6 and
>
> (select count(*) from t_pictures where status < 5 and kd_id = a.kd_id and
> li_id = a.li_id) = 0
>
> into :pfad;
>
> pfad = path for an file
>
> Now we have thousands of records in this table and the execution takes some
> minutes. How can I make this statement better? I would check If there is
> for
> a record (unique with kd_id and li_id (primary key reference) one record
> with status < 5. If no, I can delete the folder then there is no now no
> picture in it.
>
> Thanks for helping.
>
> Best regards.
>
> Olaf
>
> [Non-text portions of this message have been removed]
>
>
>


[Non-text portions of this message have been removed]