warehouse development

warehouse development

Hi guys,
nice to meet you.
I'm finishing the development of a company application to manage our warehouse.
To create a selected list for product, i've arranged following script:

lisart = List:Int();
for each y in magazzinos  [(((stock_colli > 0 && deposito == doc.deposito2) && data_scadenza_lotto >= zoho.currentdate) && (protocollo_magazzino is not null))] sort by  articolo 
{
    if (!lisart.contains(y.articolo))
    {
        lisart.add(y.articolo);
    }
}

The problem is that "magazzinos" table will pass 10.000 records, so surely we will have delay problems as well as overcome statement limit.
Can anyone help me to find a workaround to solve the problem?
Thanks in advance
Regards
Ezio