# ask-community

Spencer Nelson

07/31/2023, 5:35 PM
I’ve been using opentelemetry traces to analyze the performance of some of our dagster jobs. Something that has surprised me is the number of SQL database connections that get opened and closed. A single op is opening and closing postgres DB connections 11 times! It appears that this has to do with how dagster’s run storage and event log storage work - they have context managers like
with self.connect(): …
which are used for almost all of their methods. Is there a way to trim this down, like pool the connections somehow? Those DB connection calls account for a surprisingly high fraction of our runtime and they seem unnecessary.
👀 1
Here’s a jaeger screenshot of some of the
It looks like this is quite intentional but I’m not sure this is not the tradeoff I’d make for my application:[…]raries/dagster-postgres/dagster_postgres/event_log/

Andy Carter

09/04/2023, 7:52 AM
@Spencer Nelson appreciate this is a month back, but is this dagit issue related? I would love to resolve this issue, there is a fairly large chunk of Azure Log Analytics ingestion cost incurred from these queries too.

Spencer Nelson

09/04/2023, 1:54 PM
Yes, that looks very related. Dagster basically requires a connection pooling frontend like pgbouncer.