Skip to content

First request speed  #266

@alexnur

Description

@alexnur

Hi!

I use multicorn.ldapfdw.LdapFdw.
If I have just connected (psql) to the database, then the first query to the external table takes a long time - 6-7 seconds. After that, any similar request takes 20ms. I disconnect from the server, reconnect. Again the first query to the outer table is 6-7 seconds. How can you speed up the first request so that the extension is already loaded before any new connection? I tried to specify in the configuration file postgresql.conf options:
shared_preload_libraries = 'multicorn'
local_preload_libraries = 'multicorn'
session_preload_libraries = 'multicorn'
and restart postgresql.
Nothing changed.
load 'multicorn' - doesn't help either.

https://multicorn.readthedocs.io/en/latest/implementing-tutorial.html

Foreign Data Wrapper lifecycle

_The foreign data wrapper associated to a table is instantiated on a per-process basis, and it happens when the first query is run against it.

Usually, postgresql server processes are spawned on a per-connection basis.

During the life time of a server process, the instance is cached. That means that if you have to keep references to resources such as connections, you should establish them in the init method and cache them as instance attributes._

I am not familiar with python. What exactly needs to be written in the _init method to have a fast first request?

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