| 5904 | } |
| 5905 | |
| 5906 | static int cypher_node_selectivity(const cbm_node_pattern_t *n, const cbm_where_clause_t *w) { |
| 5907 | int s = 0; |
| 5908 | for (int i = 0; i < n->prop_count; i++) { |
| 5909 | const char *k = n->props[i].key; |
| 5910 | int v = (k && (strcmp(k, "name") == 0 || strcmp(k, "qualified_name") == 0)) ? 3 : 2; |
| 5911 | if (v > s) { |
| 5912 | s = v; |
| 5913 | } |
| 5914 | } |
| 5915 | if (w && n->variable) { |
| 5916 | int v = 0; |
| 5917 | if (w->root) { |
| 5918 | v = cypher_expr_selectivity(w->root, n->variable); |
| 5919 | } else if (!w->op || strcmp(w->op, "AND") == 0) { |
| 5920 | for (int i = 0; i < w->count; i++) { |
| 5921 | int c = cypher_cond_selectivity(&w->conditions[i], n->variable); |
| 5922 | if (c > v) { |
| 5923 | v = c; |
| 5924 | } |
| 5925 | } |
| 5926 | } |
| 5927 | if (v > s) { |
| 5928 | s = v; |
| 5929 | } |
| 5930 | } |
| 5931 | if (s == 0 && n->label) { |
| 5932 | s = 1; |
| 5933 | } |
| 5934 | return s; |
| 5935 | } |
| 5936 | |
| 5937 | static void cypher_plan_seed_from_selective_end(cbm_query_t *q) { |
| 5938 | if (!q || q->pattern_count != 1 || !q->ret || (q->pattern_optional && q->pattern_optional[0])) { |
no test coverage detected