[Python] boto3 timestream queries very slow

Discussão em 'Python' iniciado por Stack, Janeiro 22, 2025.

  1. Stack

    Stack Membro Participativo

    import boto3

    device_list = ['ARMS-GFY-D5', 'ARMS-GFY-D3']

    client = boto3.client('timestream-query')

    for device_id in device_list:
    query = f"""
    SELECT time, charge, current, voltage, temperature
    FROM "telemetryDatabase"."telemetryTable"
    WHERE device_id = '{device_id}'
    AND time > ago(24h)
    ORDER BY time
    """

    response = client.query(QueryString=query)

    • The query above entered into the AWS timestream console query editor (with device ID substituted) consistently completes in under 1 second.
    • The first device_id query executed via this python script from my dev laptop consistently takes >15s, often as much as 30-60s.
    • The second device_id query executed via this python script consistently returns in <1s

    In all cases the output is small, only about 12kB (288 rows). Reducing the time range of the query has no impact on query time.

    My laptop has a gigabit internet connection and no obvious network throughput issues to AWS.

    The table schema: [​IMG]

    Why is boto3 so much slower than AWS console, seemingly only until the client is "warm"? How can I avoid this behavior?

    Continue reading...

Compartilhe esta Página