If you need to script against the full list of items in the database, try using the rest api. You may also try adding a ?filter= parameter to the url.