pgx icon indicating copy to clipboard operation
pgx copied to clipboard

Guidance on prepared Statements

Open templatedop opened this issue 1 year ago • 1 comments

Hey! Jack firstly thanks for the library.

As pgxpool automatically creates prepared statement. I thought of checking whether my queries are used as prepared statements.

Can you guide me further please!!!!

I have added following config

config, err := pgxpool.ParseConfig(dsn)
	if err != nil {
		return nil, err
	}
config.ConnConfig.DefaultQueryExecMode = pgx.QueryExecModeCacheStatement
	config.ConnConfig.StatementCacheCapacity = 100
	config.ConnConfig.DescriptionCacheCapacity = 0

When I checked Select * from pg_prepared_statements in postgres couldn't find any info. Can you please guide further please..... Kindly help..

templatedop avatar Mar 25 '24 08:03 templatedop

Each conn has their own prepared statement cache. pgxpool doesn't maintain the cache.

The view pg_prepared_statements is local to each connection. You can only see the statements from the connection that has prepared them.

jackc avatar Mar 25 '24 09:03 jackc