The best way to solve it would be to build your own task that would connect to your database and retrieve the data in the way that you need it. Alternatively, you can build a separate task that consumes the output of this fetch task and returns the length i.e.
len
of its output