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

Use Postgres ANY for selecting many values. #6156

Merged
merged 7 commits into from Oct 10, 2019

Conversation

@erikjohnston
Copy link
Member

erikjohnston commented Oct 2, 2019

The advantage of doing col = ANY(?) rather than col IN (?,?,?,...) is mainly to make looking at postgres query stats easier.

@erikjohnston erikjohnston marked this pull request as ready for review Oct 10, 2019
@erikjohnston erikjohnston requested a review from matrix-org/synapse-core Oct 10, 2019
erikjohnston added 3 commits Oct 2, 2019
This means that we can write queries with `col = ANY(?)`, which helps
postgres.
@erikjohnston erikjohnston force-pushed the erikj/postgres_any branch from a59304e to 203ccda Oct 10, 2019
@erikjohnston

This comment has been minimized.

Copy link
Member Author

erikjohnston commented Oct 10, 2019

FTR I'm not 100% convinced that making the hand written queries more complicated is the right thing to do.

Copy link
Member

richvdh left a comment

lgtm, but a couple of thoughts.

A tuple of SQL query and the args
"""

if isinstance(database_engine, PostgresEngine):

This comment has been minimized.

Copy link
@richvdh

richvdh Oct 10, 2019

Member

i'd be tempted to make this a method on the database engine, but ymmv

@@ -1693,3 +1695,49 @@ def db_to_json(db_content):
except Exception:
logging.warning("Tried to decode '%r' as JSON and failed", db_content)
raise


def add_in_list_sql_clause(

This comment has been minimized.

Copy link
@richvdh

richvdh Oct 10, 2019

Member

I'm not convinced that this function adds much in the way of clarity tbh. I'd be inclined to inline it.

@erikjohnston erikjohnston merged commit 83d8610 into develop Oct 10, 2019
18 checks passed
18 checks passed
buildkite/synapse Build #4915 passed (20 minutes, 31 seconds)
Details
buildkite/synapse/check-sample-config Passed (2 minutes, 4 seconds)
Details
buildkite/synapse/check-style Passed (1 minute, 33 seconds)
Details
buildkite/synapse/isort Passed (41 seconds)
Details
buildkite/synapse/mypy Passed (26 seconds)
Details
buildkite/synapse/newspaper-newsfile Passed (16 seconds)
Details
buildkite/synapse/packaging Passed (20 seconds)
Details
buildkite/synapse/pipeline Passed (7 seconds)
Details
buildkite/synapse/python-3-dot-5-slash-postgres-9-dot-5 Passed (18 minutes, 6 seconds)
Details
buildkite/synapse/python-3-dot-5-slash-sqlite Passed (6 minutes, 21 seconds)
Details
buildkite/synapse/python-3-dot-5-slash-sqlite-slash-old-deps Passed (14 minutes, 25 seconds)
Details
buildkite/synapse/python-3-dot-6-slash-sqlite Passed (6 minutes, 32 seconds)
Details
buildkite/synapse/python-3-dot-7-slash-postgres-11 Passed (17 minutes, 58 seconds)
Details
buildkite/synapse/python-3-dot-7-slash-postgres-9-dot-5 Passed (17 minutes, 19 seconds)
Details
buildkite/synapse/python-3-dot-7-slash-sqlite Passed (6 minutes, 31 seconds)
Details
buildkite/synapse/sytest-python-3-dot-5-slash-postgres-9-dot-6-slash-monolith Passed (15 minutes, 31 seconds)
Details
buildkite/synapse/sytest-python-3-dot-5-slash-postgres-9-dot-6-slash-workers Passed (13 minutes, 50 seconds)
Details
buildkite/synapse/sytest-python-3-dot-5-slash-sqlite-slash-monolith Passed (13 minutes, 37 seconds)
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.