Unfortunately, it's not an apples-for-apples comparison.
Every time your app connects to a Cassandra cluster (Astra or otherwise), the driver executes these high-level steps:
- Unpack the secure bundle to get cluster info
- Open a TCP connection over the internet
- Create a control connection to one of the nodes in the cluster
- Obtain schema from the cluster using the control connection
- Discover the topology of the cluster using the control connection
- Open connections to the nodes in the cluster
- Compute query plan (list of hosts to connect to based on load-balancing policy)
- And finally, run the query
In contrast when you access the CQL Console on the Astra dashboard, the UI automatically connects + authenticates to the cluster and when you type a CQL statement it goes through the following steps:
- Skipped (you're already authenticated to the cluster)
- Skipped (it's already connected to a node within the same local VPC)
- Skipped (already connected to cluster)
- Skipped (already connected to cluster)
- Skipped (already connected to cluster)
- Skipped (already connected to cluster)
- Skipped (already connected to cluster)
- And finally, run the query
As you can see, the CQL Console does not have the same overhead as running an app repeatedly which only has 1 CQL statement in it.
In reality, your app will be reusing the same cluster session to execute queries throughout the life of the app so it doesn't have the same overhead as just re-running the app you have above. The initialisation phase (steps 1 to 6 above) are only done when the app is started. Once it's already running, it only has to do steps 7 and 8. Cheers!