Significant Query Performance Discrepancy with Impossible WHERE Conditions
Summary
This report highlights significant performance discrepancies between logically equivalent queries that should all return empty results. Although every query correctly returns 0 rows, some take way much longer to execute despite having the same semantic meaning.
Configuration
Nebula Version: 2025.10.28-nightly
Operating System: WSL2 – Ubuntu 24.04.1 LTS
Installation Method: Docker
Steps to reproduce
- Start Nebula via Docker
docker exec -it nebula-docker-compose-console-1 sh- Connect with
nebula-console:
nebula-console -u root -p nebula -addr graphd -port 9669- Run the following query:
Create a test space
CREATE SPACE IF NOT EXISTS test(partition_num=1, replica_factor=1, vid_type=FIXED_STRING(8));Select the space
use testPositive case (finish immediately; All the negative cases below can be simplified to this one):
(root@nebula) [test]> UNWIND range(1,200) AS p WITH p LIMIT 200 UNWIND range(1,5000) AS qid WITH p,qid,{age: qid % 50 + 18, score: qid % 100} AS q WHERE false RETURN p
+---+
| p |
+---+
+---+
Empty set (time spent 6.874ms/7.535431ms)Negative cases (take much longer):
Some of the buggy queries may share the same root cause; I reported all of them anyway in case they turn out to be different issues.
(root@nebula) [test]> UNWIND range(1,200) AS p WITH p LIMIT 200 UNWIND range(1,5000) AS qid WITH p, qid, {age: qid % 50 + 18, score: qid % 100} AS q WHERE 1 IS NULL RETURN p
+---+
| p |
+---+
+---+
Empty set (time spent 575.127ms/575.720116ms)(root@nebula) [test]> UNWIND range(1,200) AS p WITH p LIMIT 200 UNWIND range(1,5000) AS qid WITH p,qid,{age: qid % 50 + 18, score: qid % 100} AS q WHERE q.age == 1 AND q.age == 2 RETURN p
+---+
| p |
+---+
+---+
Empty set (time spent 588.101ms/588.586628ms)
Thu, 25 Dec 2025 07:32:32 UTC(root@nebula) [test]> UNWIND range(1,200) AS p WITH p LIMIT 200 UNWIND range(1,5000) AS qid WITH p,qid,{age: qid % 50 + 18, score: qid % 100} AS q WHERE q.score > 50 AND q.score <= 50 RETURN p
+---+
| p |
+---+
+---+
Empty set (time spent 653.891ms/654.860234ms)(root@nebula) [test]> UNWIND range(1,200) AS p WITH p LIMIT 200 UNWIND range(1,5000) AS qid WITH p,qid,{age: qid % 50 + 18, score: qid % 100} AS q WHERE reduce(s = 0, x IN range(1,0) | s + x) <> 0 RETURN p
+---+
| p |
+---+
+---+
Empty set (time spent 605.159ms/606.040144ms)(root@nebula) [test]> UNWIND range(1,200) AS p WITH p LIMIT 200 UNWIND range(1,5000) AS qid WITH p,qid,{age: qid % 50 + 18, score: qid % 100} AS q WHERE q IS NULL RETURN p
+---+
| p |
+---+
+---+
Empty set (time spent 571.493ms/573.744194ms)(root@nebula) [test]> UNWIND range(1,200) AS p WITH p LIMIT 200 UNWIND range(1,5000) AS qid WITH p,qid,{age: qid % 50 + 18, score: qid % 100} AS q WHERE q <> q RETURN p
+---+
| p |
+---+
+---+
Empty set (time spent 601.232ms/601.949854ms)(root@nebula) [test]> UNWIND range(1,200) AS p WITH p LIMIT 200 UNWIND range(1,5000) AS qid WITH p,qid,{age: qid % 50 + 18, score: qid % 100} AS q WHERE any(x IN [1] WHERE x <> x) RETURN p
+---+
| p |
+---+
+---+
Empty set (time spent 637.821ms/638.492222ms)(root@nebula) [test]> UNWIND range(1,200) AS p WITH p LIMIT 200 UNWIND range(1,5000) AS qid WITH p, {n: qid} AS m WHERE m.n IS NULL RETURN p
+---+
| p |
+---+
+---+
Empty set (time spent 400.646ms/400.976752ms)Expected behaviour
All queries should have comparable execution times, since each WHERE predicate is a constant condition that cannot evaluate to true for any row.
Actual behaviour
The positive case complete almost immediately. The negative cases take much longer.
Source: vesoft-inc/nebula