Skip to content

c/driver/postgresql: optimize startup query building table of record types #4749

Description

@lidavidm

What feature or improvement would you like to see?

As suggested at #1755 (comment) we could reduce the amount of data being queried at startup to build the type mapping table. One involves not querying every single column in the database.

An alternate suggested query:

SELECT a.attrelid, a.attname, a.atttypid
FROM pg_catalog.pg_attribute AS a
JOIN pg_catalog.pg_type AS t
  ON t.typrelid = a.attrelid
WHERE t.typtype = 'c'
  AND a.attnum > 0
  AND NOT a.attisdropped
ORDER BY a.attrelid, a.attnum

We should add a full suite of tests for different scenarios first, though, to ensure we don't break one of them (e.g. inherited tables), also we should benchmark (both time to connect and CPU usage), and perhaps expose some controls/statistics about the type table (# of entries, time to build, flush/rebuild, etc.)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions