- Newest
- Most votes
- Most comments
The performance improvement you're seeing when using toFloat(u.score) >= 0.75 instead of u.score >= 0.75 is related to how Neptune processes type conversions and optimizes query execution.
When you use u.score >= 0.75 without any type hints, Neptune has to handle potential type inconsistencies in your data. Even though you believe all values are floats, Neptune doesn't know this for certain. The query planner generates multiple constraint checks for different data types (xsd:double, xsd:float, xsd:byte, xsd:short, etc.) as shown in your query plan with multiple DFEPipelineJoin operations. This type of plan requires more processing overhead.
By explicitly using toFloat(u.score), you're forcing a specific type conversion, which allows Neptune to generate a more efficient query plan. Instead of multiple join operations for different potential data types, it can use a direct function application (DFEApply functor=ge) with constants. This eliminates the need for multiple type-specific constraint checks.
The USING QUERY:assumeConsistentDataTypes "true" directive helps by telling Neptune that properties with the same name have consistent data types, which reduces some of the type checking overhead. However, explicitly converting with toFloat() seems to provide an even more optimized execution path in your case.
This optimization is safe to use in production as long as:
- You're confident that all
scorevalues are numeric and can be converted to float - The precision differences between float and double don't affect your use case (which you mentioned is fine)
- You've tested with representative data volumes
The performance gain comes from eliminating type ambiguity, allowing Neptune to generate a more streamlined execution plan with fewer operations. This is particularly beneficial when working with large datasets like your 6 million users.
Sources
openCypher query best practices - Neptune Analytics
openCypher extensions in Amazon Neptune - Amazon Neptune
answered 9 months ago
Relevant content
asked 4 years ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 4 months ago

The AI answer here is likely the reason for what you are seeing. Neptune has to perform what we refer to as "type promotion" when explicit types are not known at query time.