Skip to content

Commit 3db6c2c

Browse files
authored
Make any query to system.local use WHERE clause (#419)
Full scan queries are slower even if there is only one record.
1 parent f05e37f commit 3db6c2c

23 files changed

+53
-53
lines changed

examples/request_init_listener.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ def __str__(self):
6868
# attach a listener to this session
6969
ra = RequestAnalyzer(session)
7070

71-
session.execute("SELECT release_version FROM system.local")
72-
session.execute("SELECT release_version FROM system.local")
71+
session.execute("SELECT release_version FROM system.local WHERE key='local'")
72+
session.execute("SELECT release_version FROM system.local WHERE key='local'")
7373

7474
print(ra)
7575
# 2 requests (0 errors)

tests/integration/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def get_server_versions():
8787

8888
c = TestCluster()
8989
s = c.connect()
90-
row = s.execute('SELECT cql_version, release_version FROM system.local').one()
90+
row = s.execute("SELECT cql_version, release_version FROM system.local WHERE key='local'").one()
9191

9292
cass_version = _tuple_version(row.release_version)
9393
cql_version = _tuple_version(row.cql_version)

tests/integration/advanced/test_auth.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def connect_and_query(self, auth_provider, query=None):
157157
os.environ['KRB5_CONFIG'] = self.krb_conf
158158
self.cluster = TestCluster(auth_provider=auth_provider)
159159
self.session = self.cluster.connect()
160-
query = query if query else "SELECT * FROM system.local"
160+
query = query if query else "SELECT * FROM system.local WHERE key='local'"
161161
statement = SimpleStatement(query)
162162
rs = self.session.execute(statement)
163163
return rs
@@ -529,4 +529,4 @@ def test_connection_with_transitional_mode(self):
529529
@expected_result connect and query should be allowed
530530
"""
531531
auth_provider = TransitionalModePlainTextAuthProvider()
532-
self.assertIsNotNone(self.connect_and_query(auth_provider, query="SELECT * from system.local"))
532+
self.assertIsNotNone(self.connect_and_query(auth_provider, query="SELECT * from system.local WHERE key='local'"))

tests/integration/advanced/test_unixsocketendpoint.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,4 @@ def tearDownClass(cls):
7171

7272
def test_unix_socket_connection(self):
7373
s = self.cluster.connect()
74-
s.execute('select * from system.local')
74+
s.execute("select * from system.local where key='local'")

tests/integration/cloud/test_cloud.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def test_match_system_local(self):
6262

6363
self.assertEqual(len(self.hosts_up()), 3)
6464
for host in self.cluster.metadata.all_hosts():
65-
row = self.session.execute('SELECT * FROM system.local', host=host).one()
65+
row = self.session.execute("SELECT * FROM system.local WHERE key='local'", host=host).one()
6666
self.assertEqual(row.host_id, host.host_id)
6767
self.assertEqual(row.rpc_address, host.broadcast_rpc_address)
6868

tests/integration/long/test_consistency.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ def test_pool_with_host_down(self):
354354
# Attempt a query against that node. It should complete
355355
cluster2 = TestCluster(contact_points=all_contact_points)
356356
session2 = cluster2.connect()
357-
session2.execute("SELECT * FROM system.local")
357+
session2.execute("SELECT * FROM system.local WHERE key='local'")
358358
finally:
359359
cluster2.shutdown()
360360
start(node_to_stop)

tests/integration/long/test_ipv6.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class IPV6ConnectionTest(object):
8080
def test_connect(self):
8181
cluster = TestCluster(connection_class=self.connection_class, contact_points=['::1'], connect_timeout=10)
8282
session = cluster.connect()
83-
future = session.execute_async("SELECT * FROM system.local")
83+
future = session.execute_async("SELECT * FROM system.local WHERE key='local'")
8484
future.result()
8585
self.assertEqual(future._current_host.address, '::1')
8686
cluster.shutdown()

tests/integration/long/test_ssl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ def test_can_connect_with_ssl_long_running(self):
193193
# attempt a few simple commands.
194194

195195
for i in range(8):
196-
rs = session.execute("SELECT * FROM system.local")
196+
rs = session.execute("SELECT * FROM system.local WHERE key='local'")
197197
time.sleep(10)
198198

199199
cluster.shutdown()

tests/integration/simulacron/test_connection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -464,14 +464,14 @@ def test_driver_recovers_nework_isolation(self):
464464
for host in cluster.metadata.all_hosts():
465465
self.assertIn(host, listener.hosts_marked_down)
466466

467-
self.assertRaises(NoHostAvailable, session.execute, "SELECT * from system.local")
467+
self.assertRaises(NoHostAvailable, session.execute, "SELECT * from system.local WHERE key='local'")
468468

469469
clear_queries()
470470
prime_request(AcceptConnections())
471471

472472
time.sleep(idle_heartbeat_timeout + idle_heartbeat_interval + 2)
473473

474-
self.assertIsNotNone(session.execute("SELECT * from system.local"))
474+
self.assertIsNotNone(session.execute("SELECT * from system.local WHERE key='local'"))
475475

476476
def test_max_in_flight(self):
477477
""" Verify we don't exceed max_in_flight when borrowing connections or sending heartbeats """

tests/integration/simulacron/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def prime_server_versions(self):
125125
if DSE_VERSION:
126126
system_local_row["dse_version"] = DSE_VERSION.base_version
127127
column_types = {"cql_version": "ascii", "release_version": "ascii"}
128-
system_local = PrimeQuery("SELECT cql_version, release_version FROM system.local",
128+
system_local = PrimeQuery("SELECT cql_version, release_version FROM system.local WHERE key='local'",
129129
rows=[system_local_row],
130130
column_types=column_types)
131131

0 commit comments

Comments
 (0)