trinodb / trino

Official repository of Trino, the distributed SQL query engine for big data, formerly known as PrestoSQL (https://trino.io)
https://trino.io
Apache License 2.0
10.45k stars 3.01k forks source link

Postgresql connector takes a long time to do syntax analysis #9279

Open liijiankang opened 3 years ago

liijiankang commented 3 years ago

Describe the current behavior

When we use trino query postgresql, the execution speed is very slow. The log shows that the value of syntaxAnalysisTime is 31863ms.

Describe the expected behavior

syntaxAnalysisTime should also finish within 1000ms.

liijiankang commented 3 years ago

After analyzing the running log and trino's call stack within this query proc. Two basic jdbc api were call to check the dst table and get its column info, when DatabaseMetaData.getTables was called, it return with in a short time spend,but when DatabaseMetaData.getColumns was called to get table's column info, it spend upto 30s to return in our working env. Because our postgresql is not regularly maintained, it has caused the system tables to bloat, causing DatabaseMetaData.getColumns to take a long time. After we cleaned the system tables, the value of syntaxAnalysisTime became very small. But cleaning up the system tables will lead to the termination of our production business. Is there any other way to solve this problem?