Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. create table test(a Int64, b Int64, c Int64, d String)
  2. engine=MergeTree partition by tuple() order by (a,b,c);
  3.  
  4. insert into test select 1, 0, number, toString(number) from numbers(1000000);
  5. insert into test select 2, 2, number, toString(number) from numbers(100);
  6. insert into test select 3, 3, number, toString(number) from numbers(1000000);
  7.  
  8. select count() from test where a=2 and c=1;
  9. 1 rows in set. Elapsed: 0.002 sec.
  10.  
  11. select count() from test prewhere a=3 and c=1;
  12. 1 rows in set. Elapsed: 0.002 sec. Processed 9.44 thousand rows, 151.10 KB (5.03 million rows/s., 80.44 MB/s.)
  13.  
  14. select count() from test where a=3;
  15. 1 rows in set. Elapsed: 0.003 sec. Processed 1.00 million rows, 8.01 MB (378.03 million rows/s., 3.02 GB/s.)
  16.  
  17. SETTINGS index_granularity = 1024
  18.  
  19. select count() from test prewhere a=3 and c=1;
  20. 1 rows in set. Elapsed: 0.002 sec. Processed 2.28 thousand rows, 36.42 KB (1.15 million rows/s., 18.43 MB/s.)
  21.  
  22.  
  23. select count() from test prewhere c=1;
  24. 1 rows in set. Elapsed: 0.009 sec. Processed 3.30 thousand rows, 26.40 KB (352.25 thousand rows/s., 2.82 MB/s.)
  25.  
  26.  
  27. ---------
  28. 2. Now the same column, the same type (a Int64) but many different values:
  29.  
  30. insert into test select number, 0, 0, toString(number) from numbers(1000000);
  31. select count() from test where c=1;
  32. 0 rows in set. Elapsed: 0.003 sec. Processed 1.00 million rows, 8.00 MB (334.18 million rows/s., 2.67 GB/s.)
  33.  
  34. select count() from test where a=1 and c=1;
  35. 0 rows in set. Elapsed: 0.001 sec. Processed 8.19 thousand rows, 131.07 KB (5.42 million rows/s., 86.69 MB/s.)
  36.  
  37. select count() from test where a>=10000 and c=1;
  38. 0 rows in set. Elapsed: 0.007 sec. Processed 991.81 thousand rows, 15.87 MB (149.90 million rows/s., 2.40 GB/s.)
  39.  
  40. select count() from test where a>=999000 and c=1;
  41. 0 rows in set. Elapsed: 0.001 sec. Processed 8.77 thousand rows, 140.29 KB (6.48 million rows/s., 103.70 MB/s.)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement