You should not run a (by comparison) slow operation like a query directly inside the configureCell function. Run the query somewhere else on the client, then in the script simply limit the results. Check this post for more information on how to do that (note that it's a fairly high-level scripting solution):