Check if a subquery returns any results (optimized for EXISTS) Returns true as soon as the first result is found, without materializing all results
(
&self,
query: &crate::ast::Query,
context: &ExecutionContext,
)
| 1063 | /// Check if a subquery returns any results (optimized for EXISTS) |
| 1064 | /// Returns true as soon as the first result is found, without materializing all results |
| 1065 | fn check_subquery_exists( |
| 1066 | &self, |
| 1067 | query: &crate::ast::Query, |
| 1068 | context: &ExecutionContext, |
| 1069 | ) -> Result<bool, ExecutionError> { |
| 1070 | use crate::ast::Query; |
| 1071 | match query { |
| 1072 | Query::Basic(basic_query) => { |
| 1073 | // For basic queries, check existence with early termination |
| 1074 | self.check_basic_query_exists(basic_query, context) |
| 1075 | } |
| 1076 | _ => { |
| 1077 | // For complex queries (set operations, limited queries), fall back to full execution |
| 1078 | // TODO: These could also be optimized for early termination in the future |
| 1079 | let result = self.execute_subquery_with_context(query, context)?; |
| 1080 | Ok(!result.rows.is_empty()) |
| 1081 | } |
| 1082 | } |
| 1083 | } |
| 1084 | |
| 1085 | /// Check if a basic query returns any results with early termination |
| 1086 | fn check_basic_query_exists( |
no test coverage detected