RE: [firebird-support] Bad performance with select first(1) + order by

2020-02-04 Thread Hugo Eyng hugoe...@msn.com [firebird-support]
Hello.

Try using a "WHERE" clause if possible.
Ex: WHERE "some_date_column_of_the_table" > (current_date - n)

Atenciosamente,

+ + Hugo Eyng + +


De: firebird-support@yahoogroups.com  em nome 
de Matthias Winkler spmm...@gmail.com [firebird-support] 

Enviado: terça-feira, 4 de fevereiro de 2020 11:36
Para: firebird-support@yahoogroups.com 
Assunto: [firebird-support] Bad performance with select first(1) + order by



Hello,

I am struggling with my DB performance once more:

   SELECT FIRST(1) PRIMKEY
   FROM TABLE_X
   ORDER BY PRIMKEY DESC

The statement is slow once more because of the sorting.
I just want to find the entry with the highest primary key.
The PRIMKEY is ASC and unique.

Is the another way to achieve the same?

Thanks

Matthias





Re: [firebird-support] Bad performance with select first(1) + order by

2020-02-04 Thread Matthias Winkler spmm...@gmail.com [firebird-support]
I fixed the update statement with

"UPDATE ... where PRIMKEY= GEN_ID(gen_primkey_counter,0)"
and execution fell from 20s to 0,4. :-)

Now a final question, what would  GEN_ID(gen_primkey_counter,0) return,
when I delete the last n entries of the table?

It's fun to implement FB with such a great and instant support! Thanks!

On Tue, Feb 4, 2020 at 1:12 PM Matthias Winkler  wrote:

> Hello SD,
>
> YES That kind of thing is what I was looking for, I guess.
> Thanks
>
> On Tue, Feb 4, 2020 at 12:52 PM Dimitry Sibiryakov s...@ibphoenix.com
> [firebird-support]  wrote:
>
>> 04.02.2020 12:47, Matthias Winkler spmm...@gmail.com [firebird-support]
>> wrote:
>> > But I need to deal with a heap of old code and re-designing
>> > it, is not a real option :-)
>>
>>Still you can use "update or insert ... matching gen_id(..., 0)"
>> instead.
>>
>>
>> --
>>WBR, SD.
>>
>>
>> 
>>
>> 
>>
>> ++
>>
>> Visit http://www.firebirdsql.org and click the Documentation item
>> on the main (top) menu.  Try FAQ and other links from the left-side menu
>> there.
>>
>> Also search the knowledgebases at
>> http://www.ibphoenix.com/resources/documents/
>>
>> ++
>> 
>>
>> Yahoo Groups Links
>>
>>
>>
>>


Re: [firebird-support] Bad performance with select first(1) + order by

2020-02-04 Thread Matthias Winkler spmm...@gmail.com [firebird-support]
Hello SD,

YES That kind of thing is what I was looking for, I guess.
Thanks

On Tue, Feb 4, 2020 at 12:52 PM Dimitry Sibiryakov s...@ibphoenix.com
[firebird-support]  wrote:

> 04.02.2020 12:47, Matthias Winkler spmm...@gmail.com [firebird-support]
> wrote:
> > But I need to deal with a heap of old code and re-designing
> > it, is not a real option :-)
>
>Still you can use "update or insert ... matching gen_id(..., 0)"
> instead.
>
>
> --
>WBR, SD.
>
>
> 
>
> 
>
> ++
>
> Visit http://www.firebirdsql.org and click the Documentation item
> on the main (top) menu.  Try FAQ and other links from the left-side menu
> there.
>
> Also search the knowledgebases at
> http://www.ibphoenix.com/resources/documents/
>
> ++
> 
>
> Yahoo Groups Links
>
>
>
>


Re: [firebird-support] Bad performance with select first(1) + order by

2020-02-04 Thread Dimitry Sibiryakov s...@ibphoenix.com [firebird-support]
04.02.2020 12:47, Matthias Winkler spmm...@gmail.com [firebird-support] wrote:
> But I need to deal with a heap of old code and re-designing
> it, is not a real option :-)

   Still you can use "update or insert ... matching gen_id(..., 0)" instead.


-- 
   WBR, SD.






++

Visit http://www.firebirdsql.org and click the Documentation item
on the main (top) menu.  Try FAQ and other links from the left-side menu there.

Also search the knowledgebases at http://www.ibphoenix.com/resources/documents/ 

++


Yahoo Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-support/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/firebird-support/join
(Yahoo! ID required)

<*> To change settings via email:
firebird-support-dig...@yahoogroups.com 
firebird-support-fullfeatu...@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
firebird-support-unsubscr...@yahoogroups.com

<*> Your use of Yahoo Groups is subject to:
https://info.yahoo.com/legal/us/yahoo/utos/terms/



Re: [firebird-support] Bad performance with select first(1) + order by

2020-02-04 Thread Matthias Winkler spmm...@gmail.com [firebird-support]
Hi SD,

no doubt, that might be solved better or more performant.
But I need to deal with a heap of old code and re-designing
it, is not a real option :-)

On Tue, Feb 4, 2020 at 12:45 PM Dimitry Sibiryakov s...@ibphoenix.com
[firebird-support]  wrote:

> 04.02.2020 12:42, Matthias Winkler spmm...@gmail.com [firebird-support]
> wrote:
> > The last entry is considered the "current" entry and should be updated
> > when the programm encounters e.g. a error.
> > (Then the field error_count of the "current" entry is then incremented)
>
>That's a bad design. The program should better only insert new records.
>
>
> --
>WBR, SD.
>
>
> 
>
> 
>
> ++
>
> Visit http://www.firebirdsql.org and click the Documentation item
> on the main (top) menu.  Try FAQ and other links from the left-side menu
> there.
>
> Also search the knowledgebases at
> http://www.ibphoenix.com/resources/documents/
>
> ++
> 
>
> Yahoo Groups Links
>
>
>
>


Re: [firebird-support] Bad performance with select first(1) + order by

2020-02-04 Thread Dimitry Sibiryakov s...@ibphoenix.com [firebird-support]
04.02.2020 12:42, Matthias Winkler spmm...@gmail.com [firebird-support] wrote:
> The last entry is considered the "current" entry and should be updated
> when the programm encounters e.g. a error.
> (Then the field error_count of the "current" entry is then incremented)

   That's a bad design. The program should better only insert new records.


-- 
   WBR, SD.






++

Visit http://www.firebirdsql.org and click the Documentation item
on the main (top) menu.  Try FAQ and other links from the left-side menu there.

Also search the knowledgebases at http://www.ibphoenix.com/resources/documents/ 

++


Yahoo Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-support/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/firebird-support/join
(Yahoo! ID required)

<*> To change settings via email:
firebird-support-dig...@yahoogroups.com 
firebird-support-fullfeatu...@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
firebird-support-unsubscr...@yahoogroups.com

<*> Your use of Yahoo Groups is subject to:
https://info.yahoo.com/legal/us/yahoo/utos/terms/



Re: [firebird-support] Bad performance with select first(1) + order by

2020-02-04 Thread Matthias Winkler spmm...@gmail.com [firebird-support]
The purpose of the code is:

The last entry is considered the "current" entry and should be updated
when the programm encounters e.g. a error.
(Then the field error_count of the "current" entry is then incremented)

On Tue, Feb 4, 2020 at 12:40 PM Svein Erling Tysvær setys...@gmail.com
[firebird-support]  wrote:

>
>
> Just create a descending index,
> Set
>
> tir. 4. feb. 2020 kl. 12:36 skrev Matthias Winkler spmm...@gmail.com
> [firebird-support] :
>
>>
>>
>> Hello,
>>
>> I am struggling with my DB performance once more:
>>
>>SELECT FIRST(1) PRIMKEY
>>FROM TABLE_X
>>ORDER BY PRIMKEY DESC
>>
>> The statement is slow once more because of the sorting.
>> I just want to find the entry with the highest primary key.
>> The PRIMKEY is ASC and unique.
>>
>> Is the another way to achieve the same?
>>
>> Thanks
>>
>> Matthias
>>
>>
>>
>> 
>


Re: [firebird-support] Bad performance with select first(1) + order by

2020-02-04 Thread Svein Erling Tysvær setys...@gmail.com [firebird-support]
Just create a descending index,
Set

tir. 4. feb. 2020 kl. 12:36 skrev Matthias Winkler spmm...@gmail.com
[firebird-support] :

>
>
> Hello,
>
> I am struggling with my DB performance once more:
>
>SELECT FIRST(1) PRIMKEY
>FROM TABLE_X
>ORDER BY PRIMKEY DESC
>
> The statement is slow once more because of the sorting.
> I just want to find the entry with the highest primary key.
> The PRIMKEY is ASC and unique.
>
> Is the another way to achieve the same?
>
> Thanks
>
> Matthias
>
>
>
> 


Re: [firebird-support] Bad performance with select first(1) + order by

2020-02-04 Thread Dimitry Sibiryakov s...@ibphoenix.com [firebird-support]
04.02.2020 12:36, Matthias Winkler spmm...@gmail.com [firebird-support] wrote:
> The PRIMKEY is ASC and unique.

   For this query it must be DESC.

> Is the another way to achieve the same?

   What's the purpose of it? Unique id generation used to be handled by 
generators.

-- 
   WBR, SD.






++

Visit http://www.firebirdsql.org and click the Documentation item
on the main (top) menu.  Try FAQ and other links from the left-side menu there.

Also search the knowledgebases at http://www.ibphoenix.com/resources/documents/ 

++


Yahoo Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-support/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/firebird-support/join
(Yahoo! ID required)

<*> To change settings via email:
firebird-support-dig...@yahoogroups.com 
firebird-support-fullfeatu...@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
firebird-support-unsubscr...@yahoogroups.com

<*> Your use of Yahoo Groups is subject to:
https://info.yahoo.com/legal/us/yahoo/utos/terms/