Subject | Re: [ib-support] Delete first 100 from table |
---|---|
Author | Don Gollahon |
Post date | 2003-06-10T21:27:10Z |
I thought of something similar to that but I think both would be too slow.
My tables can have 10 to 20 million records in them. I want to delete those
that are over 2 months old but since there could be a million records to
delete I want to delete them 100 at a time so the FB engine can process
commands from other users on other databases.
Here's my idea:
delete from master m1
where
exists(
select first 100 *
from master m2
where m1.fld1 = m2.fld1
and m1.fld2 = m2.fld2
and m1.datefld < '4/1/2003')
And then loop through that query until there are none left to delete.
"Markus Ostenried" <chef_007@...> wrote in message
news:<5.2.1.1.2.20030610222914.04932970@...>...
My tables can have 10 to 20 million records in them. I want to delete those
that are over 2 months old but since there could be a million records to
delete I want to delete them 100 at a time so the FB engine can process
commands from other users on other databases.
Here's my idea:
delete from master m1
where
exists(
select first 100 *
from master m2
where m1.fld1 = m2.fld1
and m1.fld2 = m2.fld2
and m1.datefld < '4/1/2003')
And then loop through that query until there are none left to delete.
"Markus Ostenried" <chef_007@...> wrote in message
news:<5.2.1.1.2.20030610222914.04932970@...>...
>
> Hi Don,
>
> I guess you could something like
>
> DELETE FROM YourTable
> WHERE YourField IN
> (
> SELECT FIRST 100 YourField FROM YourTable
> WHERE <your Condition>
> );
>
> HTH,
> Markus
>