Home Discussions Questions & Answers Performance Optimization with Dynamic Parameters

Performance Optimization with Dynamic Parameters

Avatar photoCustomer December 17, 2019 at 3:38 am

We currently use the traditional method for optional parameters: `column_name=nvl(:bind_variable, column_name)`. How does Blitz Report recommend handling optional parameters to maximize performance and avoid this common issue?

Viewing 4 reply threads
  • Author
    Replies
    • Support December 18, 2019 at 11:20 pm  

      Blitz Report strongly recommends using dynamic SQL anchors like the `n=n` anchor instead of the `nvl(:bind_variable, column_name)` structure. Blitz Report creates dynamic SQL at run-time, combining the extraction SQL and user parameters optimally.

    • Avatar photoCustomer December 21, 2019 at 12:00 am  

      Can you explain how the `n=n` anchor achieves performance gains for optional parameters?

    • Support December 21, 2019 at 4:15 am  

      The `n=n` (e.g., `1=1`) anchor allows unused parameters to be dynamically dropped at run-time. If a user does not enter a value for a parameter, the associated WHERE clause is omitted entirely from the generated SQL, preventing unnecessary parsing and maintaining efficient execution plans.

    • Avatar photoCustomer December 21, 2019 at 9:16 am  

      If I need to include a parameter restriction only if the user provides a value, what happens at the location of the `1=1` anchor?

    • Support December 23, 2019 at 4:35 am  

      If the user provides a value, Blitz Report inserts the parameter’s WHERE clause immediately before the `1=1` anchor, making it part of the complete WHERE clause. If no value is provided, the anchor remains intact (`WHERE 1=1 AND…`), ensuring the query executes efficiently without filtering.

Viewing 4 reply threads
  • You must be logged in to reply to this post.

Login with: