mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-09-22 15:32:48 +00:00
Fix: Postgres query column name for exec time (#22366)
This commit is contained in:
parent
16d83c8ba0
commit
5b3bb637fb
@ -509,6 +509,25 @@ def get_postgres_time_column_name(engine) -> str:
|
||||
"""
|
||||
Return the correct column name for the time column based on postgres version
|
||||
"""
|
||||
# Try to check the column in pg_stat_statements, fallback to version check if fails
|
||||
try:
|
||||
with engine.connect() as conn:
|
||||
result = conn.execute(
|
||||
"SELECT column_name FROM information_schema.columns WHERE table_name = 'pg_stat_statements'"
|
||||
)
|
||||
columns = {row[0] for row in result}
|
||||
if "total_exec_time" in columns:
|
||||
return "total_exec_time"
|
||||
elif "total_time" in columns:
|
||||
return "total_time"
|
||||
else:
|
||||
logger.warning(
|
||||
"Neither 'total_exec_time' nor 'total_time' found in pg_stat_statements. Defaulting to 'total_exec_time'."
|
||||
)
|
||||
return "total_exec_time"
|
||||
except Exception as ex:
|
||||
logger.debug(f"Failed to check columns in pg_stat_statements: {ex}")
|
||||
# Fallback to version check
|
||||
time_column_name = "total_exec_time"
|
||||
postgres_version = get_postgres_version(engine)
|
||||
if postgres_version and version.parse(postgres_version) < version.parse(
|
||||
|
Loading…
x
Reference in New Issue
Block a user