Subject | Re: [firebird-support] delete all but the newest 'n' - more efficient way |
---|---|
Author | Milan Babuskov |
Post date | 2007-03-27T16:41:06Z |
Nick Upson wrote:
quick. log2(1.000.000) is about 30, so...
--
Milan Babuskov
http://www.guacosoft.com
http://www.flamerobin.org
> This works but I want/need something more efficient, the tableIf you have indexes on OCCURREDAT and CONNECTIONLOGID it should be very
> TBLCONNECTIOLOG can be very large (say 1, 000, 000) records and this
> process could need to delete 95%.
>
> connectionlogid is the PK, generator supplied on insert
>
> This is the SP I have.
>
> select maxrecordcount from TBLSYSTEM into :maxrecordcount;
>
> select first 1 skip (:maxrecordcount) connectionlogid
> from TBLCONNECTIONLOG order by OCCURREDAT desc into :id;
>
> delete from TBLCONNECTIONLOG where connectionlogid < :id;
quick. log2(1.000.000) is about 30, so...
--
Milan Babuskov
http://www.guacosoft.com
http://www.flamerobin.org