Skip to content

src/queries/network_policy_changes/network_policy_changes.sql doing full table scan #6

@sfc-gh-jpfeiffer

Description

@sfc-gh-jpfeiffer

select user_name || ' made the following Network Policy change on ' || end_time || ' [' || query_text || ']' as Events
from SNOWFLAKE.ACCOUNT_USAGE.query_history where execution_status = 'SUCCESS'
and query_type in ('CREATE_NETWORK_POLICY', 'ALTER_NETWORK_POLICY', 'DROP_NETWORK_POLICY')
or (query_text ilike '% set network_policy%' or
query_text ilike '% unset network_policy%')

and query_type != 'SELECT' and query_type != 'UNKNOWN'
order by end_time desc;

OR logic is doing full table scan. I think you want:

select user_name || ' made the following Network Policy change on ' || end_time || ' [' || query_text || ']' as Events
from SNOWFLAKE.ACCOUNT_USAGE.query_history where execution_status = 'SUCCESS'
and
(
query_type in ('CREATE_NETWORK_POLICY', 'ALTER_NETWORK_POLICY', 'DROP_NETWORK_POLICY')
or
(query_text ilike '% set network_policy%' or query_text ilike '% unset network_policy%')
)
and query_type != 'SELECT' and query_type != 'UNKNOWN'
order by end_time desc;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions