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. ---

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 on

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-su

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

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...@

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. -

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 o

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 an

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