Skip to content

Prepared statement gains #1805

@worekleszczy

Description

@worekleszczy

Hello,

going into database logs I was surprised to see that all queries are run as unnamed prepared statements.

E.g for a postgres database with a table:

CREATE TABLE users (
id SERIAL PRIMARY KEY,
name text NOT NULL,
surname text NOT NULL
);

and a statement:

def insert(name: String, surname: String): ConnectionIO[Int] = fr"INSERT INTO users(name, surname) VALUES ($name, $surname)".update.run

insert("NAME", "SURNAME").quick.unsafeRunSync

I can see in logs:

2023-01-18 00:02:40.006 CET [94971] LOG:  execute <unnamed>: BEGIN
2023-01-18 00:02:40.007 CET [94971] LOG:  execute <unnamed>: INSERT INTO users(name, surname) VALUES ($1, $2) 
2023-01-18 00:02:40.007 CET [94971] DETAIL:  parameters: $1 = 'NAME', $2 = 'SURNAME'
2023-01-18 00:02:40.010 CET [94971] LOG:  execute S_1: COMMIT

I tried to educate myself on unnamed prepared statements, but didn't find any useful information apart from that it's only support on the wire protocol. Can you tell me what gains does it provide? Can a database still remove planning a query part event though at a first glance it's not possible to distinguish one unnamed prepared statement from the other?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions