Created
December 6, 2019 14:26
-
-
Save WesleyBatista/6fee9afeadf7535925a3a957271b9600 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import clickhouse_driver | |
def execute_query(sql, settings): | |
conn_params = { | |
'host': '<HOST>', | |
'port': 9000, | |
'user': '<USER>', | |
'password': '<PASSWORD>', | |
'database': 'default', | |
'client_name': 'throttle-testing', | |
'secure': False, | |
'verify': False, | |
'settings': settings | |
} | |
print(f'settings={settings}', ) | |
client = clickhouse_driver.Client(**conn_params) | |
result = client.execute(sql) | |
print('client.last_query.elapsed=', client.last_query.elapsed) | |
return result | |
if __name__ == "__main__": | |
settings = { | |
'max_memory_usage': 312500000, | |
'max_bytes_before_external_group_by': 156250000, | |
} | |
sql = """ | |
<SOME TIME CONSUMING QUERY WITH AGGREGATIONS> | |
""" | |
print('default profile:') | |
print(execute_query(sql, {})) | |
print() | |
print('throttled:') | |
print(execute_query(sql, settings)) | |
print() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment