GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — `WHERE n.prop IN $param` never uses the property's index; the same list written into the query does (100x on 20k vertices) · Issue #2582 · apache/age Open DescriptionDescribe the bug A property The cause looks like I found this while making every engine in a benchmark bind its values instead of pasting them: AGE was the one engine where binding a list made the query an order of magnitude slower (2.0 ms to 26.4 ms p50 in my workload), so I keep that list pasted and bind everything else. How are you accessing AGE (Command line, driver, etc.)? psql, and psycopg 3 in the application (same plans). What data setup do we need to do? LOAD 'age'; SET search_path = ag_catalog, "$user", public; SELECT create_graph('shop'); -- 20,000 products, each even pid RELATED to the next odd one SELECT * FROM cypher('shop', $$ UNWIND range(0, 9999) AS i CREATE (:Product {pid: 2 * i})-[:RELATED]->(:Product {pid: 2 * i + 1}) $$) AS (v agtype); CREATE INDEX product_pid ON shop."Product" USING btree (ag_catalog.agtype_access_operator(properties, '"pid"'::agtype)); ANALYZE; What is the necessary configuration info needed? None beyond the above. Stock What is the command that caused the error? Pasted list, uses the index: EXPLAIN (ANALYZE, COSTS OFF, TIMING OFF, SUMMARY ON) SELECT * FROM cypher('shop', $$ MATCH (a:Product)-[:RELATED]->(b) WHERE a.pid IN [16, 4242, 9000] RETURN b.pid $$) AS (pid agtype); The same list as a parameter, sequential scan: PREPARE bound(agtype) AS SELECT * FROM cypher('shop', $$ MATCH (a:Product)-[:RELATED]->(b) WHERE a.pid IN $pids RETURN b.pid $$, $1) AS (pid agtype); EXPLAIN (ANALYZE, COSTS OFF, TIMING OFF, SUMMARY ON) EXECUTE bound('{"pids": [16, 4242, 9000]}'); A single value as a parameter uses the index (0.069 ms): PREPARE one(agtype) AS SELECT * FROM cypher('shop', $$ MATCH (a:Product)-[:RELATED]->(b) WHERE a.pid = $pid RETURN b.pid $$, $1) AS (pid agtype); EXPLAIN (ANALYZE, COSTS OFF, TIMING OFF, SUMMARY ON) EXECUTE one('{"pid": 16}'); Both list forms return the same rows (17, 4243, 9001). Expected behavior
Environment (please complete the following information):
Additional context The SQL above is the whole reproduction (a fresh database, then psql). Related but different: #2548 ( Activity
MetadataMetadataAssigneesLabelsNo labels TypeProjectsMilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |