I'm running a query like:
SELECT c.Name, count(c.Enabled) as Redeemed
FROM c
WHERE NOT IS_NULL(c.Enabled)
AND c.Name NOT IN ('EXAMPLE1', 'EXAMPLE2')
GROUP BY c.Name
on a cosmos DB table (using spark.cosmos.read with a customQuery) with 50mil records and it returns one row in 0.05 seconds. The same query run on a massive Pyspark cluster takes over an hour on the action if not df.rdd.isEmpty() after executing the query.
Is this just the nature of pyspark, or am I doing the query in an inefficient way? Should I instead use no custom query, and instead filter the dataframe?
Edit: I'm not totally sure why, but adding the partitioning strategy of Restrictive to the query options made this go down to a few seconds.