use hint control sql memory managment

This commit is contained in:
obdev
2024-02-09 03:59:57 +00:00
committed by ob-robot
parent 020f901e25
commit 02fdb9b6e6
8 changed files with 40 additions and 8 deletions

View File

@ -135,6 +135,7 @@ ObPhysicalPlan::ObPhysicalPlan(MemoryContext &mem_context /* = CURRENT_CONTEXT *
is_enable_px_fast_reclaim_(false),
use_rich_format_(false),
subschema_ctx_(allocator_),
disable_auto_memory_mgr_(false),
all_local_session_vars_(&allocator_)
{
}
@ -261,6 +262,7 @@ int ObPhysicalPlan::copy_common_info(ObPhysicalPlan &src)
//copy plan_id/hint/privs
object_id_ = src.object_id_;
min_cluster_version_ = src.min_cluster_version_;
disable_auto_memory_mgr_ = src.disable_auto_memory_mgr_;
if (OB_FAIL(set_phy_plan_hint(src.get_phy_plan_hint()))) {
LOG_WARN("Failed to copy query hint", K(ret));
} else if (OB_FAIL(set_stmt_need_privs(src.get_stmt_need_privs()))) {
@ -789,7 +791,8 @@ OB_SERIALIZE_MEMBER(ObPhysicalPlan,
gtt_session_scope_ids_,
gtt_trans_scope_ids_,
use_rich_format_,
subschema_ctx_);
subschema_ctx_,
disable_auto_memory_mgr_);
int ObPhysicalPlan::set_table_locations(const ObTablePartitionInfoArray &infos,
ObSchemaGetterGuard &schema_guard)

View File

@ -478,6 +478,8 @@ public:
min_cluster_version_ = curr_cluster_version;
}
}
inline bool is_disable_auto_memory_mgr() const { return disable_auto_memory_mgr_; }
inline void disable_auto_memory_mgr() { disable_auto_memory_mgr_ = true; }
int set_logical_plan(ObLogicalPlanRawData &logical_plan);
inline ObLogicalPlanRawData& get_logical_plan() { return logical_plan_; }
@ -666,6 +668,7 @@ public:
bool is_enable_px_fast_reclaim_;
bool use_rich_format_;
ObSubSchemaCtx subschema_ctx_;
bool disable_auto_memory_mgr_;
private:
common::ObFixedArray<ObLocalSessionVar, common::ObIAllocator> all_local_session_vars_;
};

View File

@ -53,6 +53,10 @@ int ObSqlMemMgrProcessor::init(
LOG_WARN("failed to set exec info", K(ret));
} else if (OB_FAIL(alloc_dir_id(dir_id_))) {
} else if (OB_NOT_NULL(sql_mem_mgr)) {
if (OB_NOT_NULL(exec_ctx->get_physical_plan_ctx())
&& OB_NOT_NULL(exec_ctx->get_physical_plan_ctx()->get_phy_plan())) {
profile_.disable_auto_mem_mgr_ = exec_ctx->get_physical_plan_ctx()->get_phy_plan()->is_disable_auto_memory_mgr();
}
if (sql_mem_mgr->enable_auto_memory_mgr()) {
tmp_enable_auto_mem_mgr = true;
if (profile_.get_auto_policy()) {

View File

@ -43,7 +43,7 @@ public:
session_id_(-1), max_bound_(INT64_MAX), delta_size_(0), data_size_(0),
max_mem_used_(0), mem_used_(0),
pre_mem_used_(0), dumped_size_(0), data_ratio_(0.5), active_time_(0), number_pass_(0),
calc_count_(0)
calc_count_(0), disable_auto_mem_mgr_(false)
{
sql_id_[0] = '\0';
ObRandom rand;
@ -111,7 +111,7 @@ public:
OB_INLINE bool is_hash_join_wa() const { return ObSqlWorkAreaType::HASH_WORK_AREA == type_; }
OB_INLINE bool is_sort_wa() const { return ObSqlWorkAreaType::SORT_WORK_AREA == type_; }
OB_INLINE ObSqlWorkAreaType get_work_area_type() const { return type_; }
OB_INLINE bool get_auto_policy() const { return OB_INVALID_ID != expect_size_; }
OB_INLINE bool get_auto_policy() const { return !disable_auto_mem_mgr_ && OB_INVALID_ID != expect_size_; }
OB_INLINE void set_active_time(int64_t active_time) { active_time_ = active_time; }
OB_INLINE int64_t get_active_time() const { return active_time_; }
@ -199,6 +199,7 @@ public:
int64_t active_time_; // init: start_time, unregister:
int64_t number_pass_;
int64_t calc_count_; // the times of calculate global bound
bool disable_auto_mem_mgr_;
};
static constexpr const char *EXECUTION_OPTIMAL = "OPTIMAL";