There is 1000w data.
"data": {
"data": [
{
"count": 10000000
}
]
}
When I use match to query, it took about 60s.
String queryQl =
"query ProjectGraphInfo($a: string){\n" +
" ProjectGraphInfo(func: match(expert_name, $a, 3)) {\n" +
" count(uid)\n" +
" }\n" +
"}\n";
Map<String, String> vars = Collections.singletonMap("$a", "专家3");
long startTime = System.currentTimeMillis();
DgraphProto.Response res = client.newReadOnlyTransaction().queryWithVars(queryQl, vars);
long endTime = System.currentTimeMillis();
String out = Thread.currentThread().getName() + "-->" + (endTime - startTime) + "ms\n";
And the spending time is as follows:
graph-client-3-->68142ms
Are fuzzy queries so slow?Or maybe I made a mistake somewhere?
I want to know if this time is normal in 1000w data。
What do you mean by 1000w data?
When the uids are 100w, it took about 8s.
“expert_name_count”: [
{
“count”: 1000000
}
Chinese trolling … 1000w means 1,000 * 10,000 ( = 10,000,000)
Yes, 1000w = 10,000,000 and 100w = 1,000,000.
How do I make data?
private String getExpertJson() {
List<ProjectExpert> list = new ArrayList<>();
for (int i = 0; i < 10000; i++) {
ProjectExpert expert = new ProjectExpert();
expert.setPrimary_id(Long.valueOf(i));
expert.setPrimary_type("node" + i);
expert.setPrimary_data_type("expert" + i);
expert.setExpert_name("expert name:" + i);
list.add(expert);
}
@Test
public void test() {
ExecutorService executorService = new ThreadPoolExecutor(10, 10, 0, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<>(1024), new ThreadFactoryBuilder().setNameFormat("graph-client-%d").build(),
new ThreadPoolExecutor.AbortPolicy());
DgraphClient client = createDgraphClient();
//init data set schema
initGraph(client);
for (int i = 0; i < 1000; i++) {
Future<?> future = executorService.submit(() -> {
Transaction txn = null;
txn = client.newTransaction();
log.info("-----------");
String json = getExpertJson();
DgraphProto.Mutation mutation =
DgraphProto.Mutation.newBuilder().setSetJson(ByteString.copyFromUtf8(json)).build();
long startTime = System.currentTimeMillis();
try {
txn.mutate(mutation);
txn.commit();
long endTime = System.currentTimeMillis();
String out = Thread.currentThread().getName() + "-->" + (endTime - startTime) + "ms\n";
System.out.println(out);
writeFile(out);
} catch (Exception e) {
System.out.println(">>>>>>>>>>>>>>>>>>>>>");
e.printStackTrace();
} finally {
txn.discard();
}
});
try {
Object o = future.get();
}catch (Exception e){
System.out.println("///");
}
}
executorService.shutdown();
}
I see,“expert.setExpert_name(“expert name:” + i);” is the mainly reason, it makes all predicate similar.