fix(profiler): bugs in logic to fetch metrics (#9423)

This commit is contained in:
Teddy 2022-12-20 15:23:44 +01:00 committed by GitHub
parent 68ce1eed56
commit cadfb68826
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -175,12 +175,12 @@ def _(
stl_deleted = dedent(
f"""
SELECT
si."rows",
SUM(si."rows") AS "rows",
sti."database",
sti."schema",
sti."table",
sq.text,
MIN(si.starttime) AS starttime
DATE_TRUNC('second', si.starttime) AS starttime
FROM
pg_catalog.stl_delete si
INNER JOIN pg_catalog.svv_table_info sti ON si.tbl = sti.table_id
@ -191,7 +191,7 @@ def _(
sti."table" = '{table.__tablename__}' AND
"rows" != 0 AND
DATE(starttime) = CURRENT_DATE - 1
GROUP BY 1,2,3,4,5
GROUP BY 2,3,4,5,6
ORDER BY 6 desc
"""
)
@ -199,12 +199,12 @@ def _(
stl_insert = dedent(
f"""
SELECT
si."rows",
SUM(si."rows") AS "rows",
sti."database",
sti."schema",
sti."table",
sq.text,
MIN(si.starttime) AS starttime
DATE_TRUNC('second', si.starttime) AS starttime
FROM
pg_catalog.stl_insert si
INNER JOIN pg_catalog.svv_table_info sti ON si.tbl = sti.table_id
@ -215,7 +215,7 @@ def _(
sti."table" = '{table.__tablename__}' AND
"rows" != 0 AND
DATE(starttime) = CURRENT_DATE - 1
GROUP BY 1,2,3,4,5
GROUP BY 2,3,4,5,6
ORDER BY 6 desc
"""
)
@ -379,7 +379,7 @@ def _(
None,
)
if not identifier:
return None
continue
values = identifier.value.split(".")
database_name, schema_name, table_name = ([None] * (3 - len(values))) + values
@ -396,7 +396,7 @@ def _(
if (
session.get_bind().url.database.lower() == database_name
and table.__table_args__["schema"].lower() == schema_name
and table.__tablename__.lower() == table_name
and table.__tablename__ == table_name
):
cursor_for_result_scan = session.execute(
text(dedent(result_scan.format(query_id=query_result.query_id)))