Fix using MariaDB slow range select workaround with Postgresql (#88459)

* Mark PostgreSQL range select as fast

Currently we were using the slow range select workaround for
PostgreSQL that was original developed for MariaDB but
its actually slower on PostgreSQ

fixes #83253

* Mark PostgreSQL range select as fast

Currently we were using the slow range select workaround for
PostgreSQL that was original developed for MariaDB but
its actually slower on PostgreSQ

fixes #83253
This commit is contained in:
J. Nick Koston 2023-02-19 20:08:43 -06:00 committed by GitHub
parent 0b311c8c7f
commit 3533e77ec9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 2 additions and 11 deletions

View file

@ -480,7 +480,4 @@ class DatabaseOptimizer:
#
# https://jira.mariadb.org/browse/MDEV-25020
#
# Historically, we have applied this logic to PostgreSQL as well, but
# it may not be necessary. We should revisit this in the future
# when we have more data.
slow_range_in_select: bool

View file

@ -454,9 +454,8 @@ def setup_connection_for_dialect(
) -> DatabaseEngine | None:
"""Execute statements needed for dialect connection."""
version: AwesomeVersion | None = None
slow_range_in_select = True
slow_range_in_select = False
if dialect_name == SupportedDialect.SQLITE:
slow_range_in_select = False
if first_connection:
old_isolation = dbapi_connection.isolation_level
dbapi_connection.isolation_level = None
@ -533,11 +532,6 @@ def setup_connection_for_dialect(
# Ensure all times are using UTC to avoid issues with daylight savings
execute_on_connection(dbapi_connection, "SET time_zone = '+00:00'")
elif dialect_name == SupportedDialect.POSTGRESQL:
# Historically we have marked PostgreSQL as having slow range in select
# but this may not be true for all versions. We should investigate
# this further when we have more data and remove this if possible
# in the future so we can use the simpler purge SQL query for
# _select_unused_attributes_ids and _select_unused_events_ids
if first_connection:
# server_version_num was added in 2006
result = query_on_connection(dbapi_connection, "SHOW server_version")

View file

@ -460,7 +460,7 @@ def test_supported_pgsql(caplog: pytest.LogCaptureFixture, pgsql_version) -> Non
assert "minimum supported version" not in caplog.text
assert database_engine is not None
assert database_engine.optimizer.slow_range_in_select is True
assert database_engine.optimizer.slow_range_in_select is False
@pytest.mark.parametrize(