If you executed the query in shell, you will encounter timeout issue because of the volume of records its pulling.
Save it in a job definition of type redwood script and and run it. It may take a long time for the job to complete.
For better performance, narrow down the selection to fewer records, for example add one more where clause to select only job definitions that start with 'ECC%' or that belongs to particular partition.
thanks
Nanda