dse graph - gremlin - cql запрос не использует ключ раздела - PullRequest
0 голосов
/ 25 сентября 2018

Я заметил, что запрос cql, стоящий за запросом gremlin, не использует ключ раздела.Вместо этого запрос выполняет полное сканирование таблицы с разрешающим фильтром.Это вызывает проблемы с производительностью на большом графике.

Это ошибка?Я использую график DSE 6.0.1.

$ bin/dse gremlin-console

         \,,,/
         (o o)
-----oOOo-(3)-oOOo-----
plugin activated: tinkerpop.tinkergraph
plugin activated: tinkerpop.server
plugin activated: tinkerpop.utilities
gremlin> system.graph('friends').option("graph.schema_mode").set("Production").option("graph.allow_scan").set("true").option("graph.default_property_key_cardinality").set("single").create()
==>null
gremlin> system.graphs()
==>idg
==>friends
gremlin> :remote config alias g friends.g
==>g=friends.g
gremlin> g.V()
gremlin> schema.propertyKey("id_tx").Text().single().create()
==>null
gremlin> schema.propertyKey("type").Text().single().create()
==>null
gremlin> schema.propertyKey("nm").Text().single().create()
==>null
gremlin> schema.vertexLabel("person").partitionKey("id_tx").clusteringKey("type").properties("nm").create()
==>null
gremlin> graph.addVertex(label, "person", "id_tx","p10001", "type", "person", "nm","Moses")
==>v[{~label=person, id_tx="p10001", type="person"}]
gremlin> g.V()
==>v[{~label=person, id_tx="p10001", type="person"}]
gremlin> g.V().hasLabel("person").has("id_tx","p10001").has("type","person")
==>v[{~label=person, id_tx="p10001", type="person"}]
gremlin> g.V().hasLabel("person").has("id_tx","p10001").has("type","person").profile()
==>Traversal Metrics
Step                                                               Count  Traversers       Time (ms)    % Dur
=============================================================================================================
DsegGraphStep(vertex,[],(id_tx = p10001 & label...                     1           1           5.953    84.58
  query-optimizer                                                                              0.227
    \_condition=((id_tx = p10001 & label = person & type = person) & (true))
  query-setup                                                                                  0.031
    \_isFitted=true
    \_isSorted=false
    \_isScan=false
  query-optimizer                                                                              0.084
    \_condition=((label = ~~vertex_exists) & (true))
  query-setup                                                                                  0.005
    \_isFitted=true
    \_isSorted=false
    \_isScan=false
  vertex-query                                                                                 0.322
    \_usesCache=false
    \_statement=SELECT * FROM "friends"."person_p" WHERE "id_tx" = ? AND "type" = ? LIMIT ? ALLOW FILTERING; 
                with params (java.lang.String) p10001, (java.lang.String) person, (java.lang.Integer) 50000
    \_options=Options{consistency=Optional[ONE], serialConsistency=Optional.empty, fallbackConsistency=Option
              al.empty, pagingState=null, pageSize=-1, user=Optional[dse_admin], waitForSchemaAgreement=true,
               async=true}
    \_usesIndex=false
DsegPropertyLoadStep                                                   1           1           1.085    15.42
                                            >TOTAL                     -           -           7.039        -
gremlin> g.V().hasLabel("person").has("id_tx","p10001")
==>v[{~label=person, id_tx="p10001", type="person"}]
gremlin> g.V().hasLabel("person").has("id_tx","p10001").profile()
==>Traversal Metrics
Step                                                               Count  Traversers       Time (ms)    % Dur
=============================================================================================================
DsegGraphStep(vertex,[],(id_tx = p10001 & label...                     1           1           2.020    83.65
  query-optimizer                                                                              0.239
    \_condition=((id_tx = p10001 & label = person) & (true))
  query-setup                                                                                  0.009
    \_isFitted=false
    \_isSorted=false
    \_isScan=true
  index-query                                                                                  0.417
    \_usesCache=false
    \_statement=SELECT "id_tx", "type" FROM "friends"."person_p" WHERE "~~vertex_exists" = ? LIMIT ? ALLOW FI
                LTERING; with params (java.lang.Boolean) true, (java.lang.Integer) 50000
    \_options=Options{consistency=Optional[ONE], serialConsistency=Optional.empty, fallbackConsistency=Option
              al.empty, pagingState=null, pageSize=-1, user=Optional[dse_admin], waitForSchemaAgreement=true,
               async=true}
DsegPropertyLoadStep                                                   1           1           0.394    16.35
                                            >TOTAL                     -           -           2.415        -
gremlin> 

Вот схема и команды, которые я использовал для воссоздания.

system.graph('friends').option("graph.schema_mode").set("Production").option("graph.allow_scan").set("true").option("graph.default_property_key_cardinality").set("single").create()

schema.propertyKey("id_tx").Text().single().create()
schema.propertyKey("type").Text().single().create()
schema.propertyKey("nm").Text().single().create()

schema.vertexLabel("person").partitionKey("id_tx").clusteringKey("type").properties("nm").create()

graph.addVertex(label, "person", "id_tx","p10001", "type", "person", "nm","Moses")

Обратите внимание на план выполнения

\_statement=SELECT "id_tx", "type" FROM "friends"."person_p" WHERE "~~vertex_exists" = ? LIMIT ? ALLOW FI
                    LTERING; 
...