select promotions,total,cast(promotions as decimal(15,4))/cast(total as decimal(15,4))*100
from
(select sum(ss_ext_sales_price) promotions
from store_sales
,store
,promotion
,date_dim
,customer
,customer_address
,item
where ss_sold_date_sk = d_date_sk
and ss_store_sk = s_store_sk
and ss_promo_sk = p_promo_sk
and ss_customer_sk= c_customer_sk
and ca_address_sk = c_current_addr_sk
and ss_item_sk = i_item_sk
and ca_gmt_offset = -7
and i_category = 'Sports'
and (p_channel_dmail = 'Y' or p_channel_email = 'Y' or p_channel_tv = 'Y')
and s_gmt_offset = -7
and d_year = 2000
and d_moy = 11) promotional_sales,
(select sum(ss_ext_sales_price) total
from store_sales
,store
,date_dim
,customer
,customer_address
,item
where ss_sold_date_sk = d_date_sk
and ss_store_sk = s_store_sk
and ss_customer_sk= c_customer_sk
and ca_address_sk = c_current_addr_sk
and ss_item_sk = i_item_sk
and ca_gmt_offset = -7
and i_category = 'Sports'
and s_gmt_offset = -7
and d_year = 2000
and d_moy = 11) all_sales
order by promotions, total
limit 100;
stack trace:
0x00007fe969b74277 in raise () from /lib64/libc.so.6
(gdb) bt
#0 0x00007fe969b74277 in raise () from /lib64/libc.so.6
#1 0x00007fe969b75968 in abort () from /lib64/libc.so.6
#2 0x00000000008a0852 in ExceptionalCondition (conditionName=conditionName@entry=0x7fe961b85b90 "!(currentAnchorTable != ((void *)0))",
errorType=errorType@entry=0x7fe961b7aa1f "FailedAssertion", fileName=fileName@entry=0x7fe961b85a43 "planner/multi_join_order.c", lineNumber=lineNumber@entry=836)
at assert.c:54
#3 0x00007fe961b350e4 in LocalJoin (currentJoinNode=0x7fe954af8798, candidateTable=0x7fe954ae3588, applicableJoinClauses=0x7fe954afc5b0, joinType=<optimized out>)
at planner/multi_join_order.c:836
#4 0x00007fe961b34c93 in EvaluateJoinRules (joinedTableList=joinedTableList@entry=0x7fe954af3b38, currentJoinNode=currentJoinNode@entry=0x7fe954af8798,
candidateTable=0x7fe954ae3588, joinClauseList=joinClauseList@entry=0x7fe954ae2f38, joinType=joinType@entry=JOIN_INNER) at planner/multi_join_order.c:646
#5 0x00007fe961b34e05 in JoinOrderForTable (firstTable=<optimized out>, tableEntryList=tableEntryList@entry=0x7fe954ae3478, joinClauseList=joinClauseList@entry=0x7fe954ae2f38)
at planner/multi_join_order.c:336
#6 0x00007fe961b34ebe in JoinOrderList (tableEntryList=tableEntryList@entry=0x7fe954ae3478, joinClauseList=joinClauseList@entry=0x7fe954ae2f38) at planner/multi_join_order.c:260
#7 0x00007fe961b3b619 in MultiNodeTree (queryTree=queryTree@entry=0x24f0f30) at planner/multi_logical_planner.c:733
#8 0x00007fe961b3b6e7 in MultiLogicalPlanCreate (originalQuery=originalQuery@entry=0x7fe95494f5c8, queryTree=queryTree@entry=0x24f0f30,
plannerRestrictionContext=plannerRestrictionContext@entry=0x7fe954991d78) at planner/multi_logical_planner.c:138
#9 0x00007fe961b30bbd in CreateDistributedPlan (planId=planId@entry=2, originalQuery=originalQuery@entry=0x7fe95494f5c8, query=query@entry=0x24f0f30,
boundParams=boundParams@entry=0x0, hasUnresolvedParams=hasUnresolvedParams@entry=false, plannerRestrictionContext=plannerRestrictionContext@entry=0x7fe954991d78)
at planner/distributed_planner.c:757
#10 0x00007fe961b31066 in CreateDistributedPlannedStmt (planId=2, localPlan=localPlan@entry=0x7fe954abca98, originalQuery=originalQuery@entry=0x7fe95494f5c8,
query=query@entry=0x24f0f30, boundParams=boundParams@entry=0x0, plannerRestrictionContext=plannerRestrictionContext@entry=0x7fe954991d78) at planner/distributed_planner.c:498
#11 0x00007fe961b31329 in distributed_planner (parse=0x24f0f30, cursorOptions=0, boundParams=0x0) at planner/distributed_planner.c:158
#12 0x00000000006df5d6 in planner (parse=parse@entry=0x24f0f30, cursorOptions=cursorOptions@entry=0, boundParams=boundParams@entry=0x0) at planner.c:260
#13 0x00007fe961b472a6 in CreateDistributedSubPlan (subPlanId=subPlanId@entry=1, subPlanQuery=subPlanQuery@entry=0x24f0f30) at planner/recursive_planning.c:1176
#14 0x00007fe961b47942 in RecursivelyPlanSubquery (subquery=subquery@entry=0x24f0f30, planningContext=planningContext@entry=0x7ffce02d7120) at planner/recursive_planning.c:1123
#15 0x00007fe961b48223 in RecursivelyPlanSubqueryWalker (node=0x24f0f30, context=0x7ffce02d7120) at planner/recursive_planning.c:836
#16 0x00000000006859ca in range_table_walker (rtable=<optimized out>, walker=walker@entry=0x7fe961b481cb <RecursivelyPlanSubqueryWalker>, context=context@entry=0x7ffce02d7120,
flags=flags@entry=0) at nodeFuncs.c:2328
#17 0x0000000000685be2 in query_tree_walker (query=query@entry=0x24efe70, walker=walker@entry=0x7fe961b481cb <RecursivelyPlanSubqueryWalker>,
context=context@entry=0x7ffce02d7120, flags=flags@entry=0) at nodeFuncs.c:2288
#18 0x00007fe961b4806d in RecursivelyPlanSubqueriesAndCTEs (query=query@entry=0x24efe70, context=context@entry=0x7ffce02d7120) at planner/recursive_planning.c:267
#19 0x00007fe961b48120 in GenerateSubplansForSubqueriesAndCTEs (planId=planId@entry=1, originalQuery=originalQuery@entry=0x24efe70,
plannerRestrictionContext=plannerRestrictionContext@entry=0x7fe96b38cf60) at planner/recursive_planning.c:205
#20 0x00007fe961b30a68 in CreateDistributedPlan (planId=planId@entry=1, originalQuery=originalQuery@entry=0x24efe70, query=query@entry=0x24d4018,
boundParams=boundParams@entry=0x0, hasUnresolvedParams=hasUnresolvedParams@entry=false, plannerRestrictionContext=plannerRestrictionContext@entry=0x7fe96b38cf60)
at planner/distributed_planner.c:685
#21 0x00007fe961b31066 in CreateDistributedPlannedStmt (planId=1, localPlan=localPlan@entry=0x7fe95494fe98, originalQuery=originalQuery@entry=0x24efe70,
query=query@entry=0x24d4018, boundParams=boundParams@entry=0x0, plannerRestrictionContext=plannerRestrictionContext@entry=0x7fe96b38cf60) at planner/distributed_planner.c:498
#22 0x00007fe961b31329 in distributed_planner (parse=0x24d4018, cursorOptions=256, boundParams=0x0) at planner/distributed_planner.c:158
#23 0x00000000006df5d6 in planner (parse=parse@entry=0x24d4018, cursorOptions=cursorOptions@entry=256, boundParams=boundParams@entry=0x0) at planner.c:260
#24 0x000000000079328a in pg_plan_query (querytree=querytree@entry=0x24d4018, cursorOptions=cursorOptions@entry=256, boundParams=boundParams@entry=0x0) at postgres.c:832
#25 0x000000000079338f in pg_plan_queries (querytrees=<optimized out>, cursorOptions=cursorOptions@entry=256, boundParams=boundParams@entry=0x0) at postgres.c:898
#26 0x000000000079366b in exec_simple_query (
query_string=query_string@entry=0x23a2828 "select promotions,total,cast(promotions as decimal(15,4))/cast(total as decimal(15,4))*100\nfrom\n (select sum(ss_ext_sales_price) promotions\n from store_sales\n ,store\n ,promotion\n "...) at postgres.c:1073
#27 0x0000000000795421 in PostgresMain (argc=<optimized out>, argv=argv@entry=0x2416d90, dbname=0x2416c28 "postgres", username=<optimized out>) at postgres.c:4182
#28 0x0000000000717164 in BackendRun (port=port@entry=0x240d340) at postmaster.c:4361
#29 0x0000000000719da3 in BackendStartup (port=port@entry=0x240d340) at postmaster.c:4033
#30 0x000000000071a04c in ServerLoop () at postmaster.c:1706
#31 0x000000000071b2e6 in PostmasterMain (argc=argc@entry=3, argv=argv@entry=0x239cb50) at postmaster.c:1379
#32 0x000000000068397f in main (argc=3, argv=0x239cb50) at main.c:228
The query does seem to run (slowly, using re-partitioning) on production builds, but gives an assert failure in
LocalJoin
.Query 61:
stack trace: