Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make insert query column ordering deterministic #556

Closed
wants to merge 1 commit into from
Closed

make insert query column ordering deterministic #556

wants to merge 1 commit into from

Conversation

rausnitz
Copy link

@rausnitz rausnitz commented Mar 9, 2023

When composing insert queries, the order of the columns is non-deterministic. This hurts query monitoring and analytics.

In a Postgres database we work with, SELECT * FROM pg_stat_statements WHERE query like 'INSERT INTO "my_insert_heavy_table"%'; returns more than 3,100 rows. The relevant table my_insert_heavy_table has many columns, thus many possible column orders when it's non-deterministic. I think if we make the order deterministic, these 3,100 different queries could be treated as one query for monitoring purposes.

Resolves #543

@gwynne
Copy link
Member

gwynne commented Mar 10, 2023

I had an idea for a better way to handle this which not only makes INSERT queries behave deterministically, but also actually improves the performance instead of worsening it. I implemented it on an identically-named branch which I will open a new PR for momentarily.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generated queries have non-deterministic ordering of columns, which trash monitoring/logging/performance
2 participants