--------------------------------------------------------------------------- @function: COptTasks::OptimizeTask @doc: task that does the optimizes query to physical DXL ---------------------------------------------------------------------------
| 880 | // |
| 881 | //--------------------------------------------------------------------------- |
| 882 | void * |
| 883 | COptTasks::OptimizeTask(void *ptr) |
| 884 | { |
| 885 | GPOS_ASSERT(nullptr != ptr); |
| 886 | SOptContext *opt_ctxt = SOptContext::Cast(ptr); |
| 887 | |
| 888 | GPOS_ASSERT(nullptr != opt_ctxt->m_query); |
| 889 | GPOS_ASSERT(nullptr == opt_ctxt->m_plan_dxl); |
| 890 | GPOS_ASSERT(nullptr == opt_ctxt->m_plan_stmt); |
| 891 | |
| 892 | AUTO_MEM_POOL(amp); |
| 893 | CMemoryPool *mp = amp.Pmp(); |
| 894 | |
| 895 | // Does the metadatacache need to be reset? |
| 896 | // |
| 897 | // On the first call, before the cache has been initialized, we |
| 898 | // don't care about the return value of MDCacheNeedsReset(). But |
| 899 | // we need to call it anyway, to give it a chance to initialize |
| 900 | // the invalidation mechanism. |
| 901 | bool reset_mdcache = gpdb::MDCacheNeedsReset(); |
| 902 | |
| 903 | // initialize metadata cache, or purge if needed, or change size if requested |
| 904 | if (!CMDCache::FInitialized()) |
| 905 | { |
| 906 | CMDCache::Init(); |
| 907 | CMDCache::SetCacheQuota(optimizer_mdcache_size * 1024L); |
| 908 | } |
| 909 | else if (reset_mdcache) |
| 910 | { |
| 911 | CMDCache::Reset(); |
| 912 | CMDCache::SetCacheQuota(optimizer_mdcache_size * 1024L); |
| 913 | } |
| 914 | else if (CMDCache::ULLGetCacheQuota() != |
| 915 | (ULLONG) optimizer_mdcache_size * 1024L) |
| 916 | { |
| 917 | CMDCache::SetCacheQuota(optimizer_mdcache_size * 1024L); |
| 918 | } |
| 919 | |
| 920 | |
| 921 | // load search strategy |
| 922 | CSearchStageArray *search_strategy_arr = |
| 923 | LoadSearchStrategy(mp, optimizer_search_strategy_path); |
| 924 | |
| 925 | CBitSet *trace_flags = nullptr; |
| 926 | CBitSet *enabled_trace_flags = nullptr; |
| 927 | CBitSet *disabled_trace_flags = nullptr; |
| 928 | CDXLNode *plan_dxl = nullptr; |
| 929 | |
| 930 | IMdIdArray *col_stats = nullptr; |
| 931 | MdidHashSet *rel_stats = nullptr; |
| 932 | |
| 933 | GPOS_TRY |
| 934 | { |
| 935 | // set trace flags |
| 936 | trace_flags = CConfigParamMapping::PackConfigParamInBitset( |
| 937 | mp, CXform::ExfSentinel, opt_ctxt->m_create_vec_plan); |
| 938 | SetTraceflags(mp, trace_flags, &enabled_trace_flags, |
| 939 | &disabled_trace_flags); |
nothing calls this directly
no test coverage detected