diff --git a/lib/spatial_features/has_spatial_features.rb b/lib/spatial_features/has_spatial_features.rb
index <HASH>..<HASH> 100644
--- a/lib/spatial_features/has_spatial_features.rb
+++ b/lib/spatial_features/has_spatial_features.rb
@@ -24,8 +24,8 @@ module SpatialFeatures
     # NOTE: features are never updated, only deleted and created, therefore we can
     # tell if they have changed by finding the maximum id and count instead of needing timestamps
     def features_cache_key
-      max_id, count = features.pluck("MAX(id), COUNT(*)").first
-      "#{name}/#{max_id}-#{count}"
+      # Do two separate queries because it is much faster for some reason
+      "#{name}/#{features.maximum(:id)}-#{features.count}"
     end
 
     def intersecting(other, options = {})
diff --git a/lib/spatial_features/version.rb b/lib/spatial_features/version.rb
index <HASH>..<HASH> 100644
--- a/lib/spatial_features/version.rb
+++ b/lib/spatial_features/version.rb
@@ -1,3 +1,3 @@
 module SpatialFeatures
-  VERSION = "1.5.5"
+  VERSION = "1.5.6"
 end
Speed up cache key calculation.

Do two separate queries because it is much faster for some reason.