Hi,
I am testing routable queries and running into problems when Vertica chooses different buddy projections for the tables. Here is the setup:
CREATE TABLE location
(
objectid int NOT NULL
)
ORDER BY objectid
SEGMENTED BY hash(objectid) ALL NODES KSAFE 1;
CREATE TABLE Response
(
objectId int NOT NULL,
beginDate timestamp NOT NULL,
locationObjectId int /* foreign key for location.objectId */
)
ORDER BY locationObjectId, beginDate
SEGMENTED BY hash(locationObjectId) ALL NODES KSAFE 1;
The query:
select count(*) from Response r
join location l on r.locationObjectId = l.objectId
and r.locationObjectId = 210
and l.objectId = 210
The (filtered) explain plan:
Access Path:
+-GROUPBY NOTHING [Cost: 206, Rows: 1] (PATH ID: 1)
| Aggregates: count(*)
| Execute on: v_vert_warehouse_082115_node0003
| +---> JOIN MERGEJOIN(inputs presorted) [Cost: 205, Rows: 143] (PATH ID: 2) Inner (BROADCAST)
| | Join Cond: (r.locationObjectId = l.objectid)
| | Execute on: v_vert_warehouse_082115_node0003
| | +-- Outer -> STORAGE ACCESS for r [Cost: 109, Rows: 28K] (PATH ID: 3)
| | | Projection: vertica_f.Response_b1
| | | Materialize: r.locationObjectId
| | | Filter: (r.locationObjectId = 210)
| | | Execute on: v_vert_warehouse_082115_node0003
| | | Runtime Filter: (SIP1(MergeJoin): r.locationObjectId)
| | +-- Inner -> STORAGE ACCESS for l [Cost: 93, Rows: 6K] (PATH ID: 4)
| | | Projection: vertica_f.location_b0
| | | Materialize: l.objectid
| | | Filter: (l.objectid = 210)
| | | Execute on: v_vert_warehouse_082115_node0002
Notice the bolded parts. Vertica is choosing the b0 projection on node 0002 for location, and the b1 projection for Response on node 0003. When I try to run this as a routable query (from jdbc or vsql), I get the following error:
ROLLBACK: Attempt to run multi-node KV plan
The weird part is that this happens on one test instance of our database, but not on another that has the same schema / data loaded. On the other instance, the b0 projections are chosen for both tables and the routable query succeeds.
So my question is, how does Vertica choose which buddy projection to use? It seems like mixed buddy projections will always result in a failure for a routable query. Is there a way to specifically instruct Vertica that it should not mix the buddy projection offsets for a routable query?