Create Index
CREATE INDEX IF NOT EXISTS idx__test__int_1 ON test(int_1);Count
0: jdbc:phoenix:localhost,bd2,bd37:2181> select count(*) from test;+------------+
| COUNT(1) |
+------------+
| 112072822 |
+------------+
1 row selected (135.8 seconds)
Count with index
0: jdbc:phoenix:localhost,bd2,bd37:2181> select count(int_1) from test where int_1 > 500;+--------------+
| COUNT(INT_1) |
+--------------+
| 55919865 |
+--------------+
1 row selected (139.147 seconds)
0: jdbc:phoenix:localhost,bd2,bd37:2181> select count(int_1) from test where int_1 > 10;
+--------------+
| COUNT(INT_1) |
+--------------+
| 110838425 |
+--------------+
1 row selected (88.276 seconds)
Group by
0: jdbc:phoenix:localhost,bd2,bd37:2181> select count(*), int_1 from test where int_1 > 995 group by int_1;+------------+------------+
| COUNT(1) | INT_1 |
+------------+------------+
| 112018 | 996 |
| 111647 | 997 |
| 112242 | 998 |
| 112461 | 999 |
+------------+------------+
4 rows selected (53.37 seconds)
0: jdbc:phoenix:localhost,bd2,bd37:2181> select count(*), int_1 from test where int_1 > 500 group by int_1;
[a lot of result]
499 rows selected (62.13 seconds)
Try it now, good luck!