Help me understand the speed difference between two DataTable requests

I wouldn’t expect q.any_of to do any caching, so your first query:

Is doing that customer search for every row in the event table. q.any_of is on of those situations where you’re better off pulling the customer results into a Python list, and then expanding that in your query. Same with the location search.

I’m not surprised that version is taking so long. Query operators are just simple translation functions that convert their arguments into proper syntax for the database.

1 Like