mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-05-20 06:50:37 +00:00
perf: change current schema and catalog to borrow, clone only necessary (#2116)
perf: change current schema and catalog to borrow, clone only when necessary Co-authored-by: gongzhengyang <gongzhengyang@bolean.com.cn>
This commit is contained in:
@@ -65,8 +65,8 @@ impl Instance {
|
||||
ctx: QueryContextRef,
|
||||
) -> Result<Output> {
|
||||
let catalog_list = new_dummy_catalog_list(
|
||||
&ctx.current_catalog(),
|
||||
&ctx.current_schema(),
|
||||
ctx.current_catalog(),
|
||||
ctx.current_schema(),
|
||||
self.catalog_manager.clone(),
|
||||
)
|
||||
.await?;
|
||||
@@ -75,8 +75,8 @@ impl Instance {
|
||||
.decode(
|
||||
plan_bytes.as_slice(),
|
||||
Arc::new(catalog_list) as Arc<_>,
|
||||
&ctx.current_catalog(),
|
||||
&ctx.current_schema(),
|
||||
ctx.current_catalog(),
|
||||
ctx.current_schema(),
|
||||
)
|
||||
.await
|
||||
.context(DecodeLogicalPlanSnafu)?;
|
||||
@@ -131,8 +131,8 @@ impl Instance {
|
||||
) -> Result<Output> {
|
||||
let results = future::try_join_all(requests.inserts.into_iter().map(|insert| {
|
||||
let catalog_manager = self.catalog_manager.clone();
|
||||
let catalog = ctx.current_catalog();
|
||||
let schema = ctx.current_schema();
|
||||
let catalog = ctx.current_catalog().to_owned();
|
||||
let schema = ctx.current_schema().to_owned();
|
||||
|
||||
common_runtime::spawn_write(async move {
|
||||
let table_name = &insert.table_name.clone();
|
||||
@@ -163,8 +163,8 @@ impl Instance {
|
||||
}
|
||||
|
||||
async fn handle_delete(&self, request: DeleteRequest, ctx: QueryContextRef) -> Result<Output> {
|
||||
let catalog = &ctx.current_catalog();
|
||||
let schema = &ctx.current_schema();
|
||||
let catalog = ctx.current_catalog();
|
||||
let schema = ctx.current_schema();
|
||||
let table_name = &request.table_name.clone();
|
||||
let table_ref = TableReference::full(catalog, schema, table_name);
|
||||
|
||||
|
||||
@@ -233,12 +233,12 @@ pub fn table_idents_to_full_name(
|
||||
) -> Result<(String, String, String)> {
|
||||
match &obj_name.0[..] {
|
||||
[table] => Ok((
|
||||
query_ctx.current_catalog(),
|
||||
query_ctx.current_schema(),
|
||||
query_ctx.current_catalog().to_owned(),
|
||||
query_ctx.current_schema().to_owned(),
|
||||
table.value.clone(),
|
||||
)),
|
||||
[schema, table] => Ok((
|
||||
query_ctx.current_catalog(),
|
||||
query_ctx.current_catalog().to_owned(),
|
||||
schema.value.clone(),
|
||||
table.value.clone(),
|
||||
)),
|
||||
@@ -260,7 +260,10 @@ pub fn idents_to_full_database_name(
|
||||
query_ctx: &QueryContextRef,
|
||||
) -> Result<(String, String)> {
|
||||
match &obj_name.0[..] {
|
||||
[database] => Ok((query_ctx.current_catalog(), database.value.clone())),
|
||||
[database] => Ok((
|
||||
query_ctx.current_catalog().to_owned(),
|
||||
database.value.clone(),
|
||||
)),
|
||||
[catalog, database] => Ok((catalog.value.clone(), database.value.clone())),
|
||||
_ => error::InvalidSqlSnafu {
|
||||
msg: format!(
|
||||
|
||||
@@ -48,7 +48,7 @@ impl SqlHandler {
|
||||
let schema = req.db_name;
|
||||
if self
|
||||
.catalog_manager
|
||||
.schema_exist(&catalog, &schema)
|
||||
.schema_exist(catalog, &schema)
|
||||
.await
|
||||
.context(CatalogSnafu)?
|
||||
{
|
||||
@@ -60,7 +60,7 @@ impl SqlHandler {
|
||||
}
|
||||
|
||||
let reg_req = RegisterSchemaRequest {
|
||||
catalog,
|
||||
catalog: catalog.to_owned(),
|
||||
schema: schema.clone(),
|
||||
};
|
||||
let _ = self
|
||||
|
||||
Reference in New Issue
Block a user