квесты о первичном индексе раздела в терадате - PullRequest
0 голосов
/ 08 мая 2018

я создаю первичный индекс раздела в таблице,

create TABLE customerservice.ordertbl_new
(
ORDER_ID  integer NOT NULL,
CUST_ID integer NOT NULL,
ORDER_DATE  date ,
ORDER_AMOUNT integer
)
PRIMARY INDEX (CUST_ID)
PARTITION BY case_n(
ORDER_AMOUNT  < 10000 ,
ORDER_AMOUNT  < 20000 ,
ORDER_AMOUNT  < 30000,
NO case OR UNKNOWN);

и затем я вставляю следующие данные:

insert into customerservice.ordertbl_new values(10001,2,'2012-01-24',548);
insert into customerservice.ordertbl_new values(10002,1,'2012-03-01',23565);
insert into customerservice.ordertbl_new values(10003,1,'2012-05-15',57846);
insert into customerservice.ordertbl_new values(10004,3,'2012-01-21',5408);
insert into customerservice.ordertbl_new values(10005,4,'2012-03-02',89655);
insert into customerservice.ordertbl_new values(10006,2,'2012-01-25',32645);
insert into customerservice.ordertbl_new values(10007,5,'2012-03-30',458);
insert into customerservice.ordertbl_new values(10008,4,'2012-04-09',7895);
insert into customerservice.ordertbl_new values(10009,3,'2012-05-01',9654);
insert into customerservice.ordertbl_new values(10010,1,'2012-02-28',23547);
insert into customerservice.ordertbl_new values(10011,2,'2012-04-14',1548);

Теперь я пытаюсь запросить эту таблицу следующим образом,

explain sel * from customerservice.ordertbl_new where order_amount < 10000;

вот результат:

Explanation
---------------------------------------------------------------------------
1) First, we lock a distinct customerservice."pseudo table" for read
 on a RowHash to prevent global deadlock for
 customerservice.ordertbl_new.
2) Next, we lock customerservice.ordertbl_new for read.
3) We do an all-AMPs RETRIEVE step from 2 partitions of
 customerservice.ordertbl_new with a condition of (
 "customerservice.ordertbl_new.ORDER_AMOUNT < 10000") into Spool 1
 (group_amps), which is built locally on the AMPs.  The size of
 Spool 1 is estimated with no confidence to be 2 rows (124 bytes).
 The estimated time for this step is 0.06 seconds.
4) Finally, we send out an END TRANSACTION step to all AMPs involved
 in processing the request.
-> The contents of Spool 1 are sent back to the user as the result of
 statement 1.  The total estimated time is 0.06 seconds.

У меня вопрос: почему он выполняет шаг для всех усилителей с двух разделов? все записи с суммой заказа менее 10000 должны быть расположены в одном разделе, почему 2 раздела здесь?

...